I am manipulating the items in the list which System.Management.ManagementObjectCollection. Each of these elements represents a System.Management.ManagementObjectone that contains properties indexed by a string. Cm:
foreach (ManagementObject queryObj in searcher.Get())
{
string osversion = (string)queryObj["Version"];
string os = (string)queryObj["Name"];
uint spmajor = (uint)queryObj["ServicePackMajorVersion"];
uint spminor = (uint)queryObj["ServicePackMinorVersion"];
...
...
...
}
Each "access to the dictionary" before queryObjreturns C # object, which in fact is what the property should be - I must know their "real" type in advance and this is normal.
The problem is that I get a InvalidCastExceptionin uint. I have to use the real type, which ushort. Should the personality from ushortto be acceptable and obvious uint?
, , string, , uint int long?