我有以下结构;
static Memory memory;
public struct Memory
{
public string Name;
public string Manufacturer;
public string MemoryType ;
public string Speed;
public string DeviceLocator;
public string Capacity;
public string OtherInfo;
};
除了以下内容,我可以获得所有内容:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");
ManagementObjectCollection myobject = searcher.Get();
foreach (ManagementObject item in myobject)
{
memory.OtherInfo = item["OtherIdentifyingInfo"].ToString();
}
当我尝试执行上述操作时,我得到:
Object reference not set to an instance of an object.
我必须以某种方式创建一个实例 item["OtherIdentifyingInfo"]
吗?