当我编译以下两个代码时,它给出了相同的结果(我认为是这样)。
//ManagementObject :
SelectQuery query = new SelectQuery("Win32_Environment");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementObject envVar in searcher.Get())
Console.WriteLine("Variable : {0}, Value = {1}",envVar["Name"], envVar["VariableValue"]);
//ManagementBaseObject :
SelectQuery query = new SelectQuery("Win32_Environment");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
foreach (ManagementBaseObject envVar in searcher.Get())
Console.WriteLine("Variable : {0}, Value = {1}",envVar["Name"], envVar["VariableValue"]);
两种代码执行有什么区别......?