Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WMI data & Arrays in C#

254 views
Skip to first unread message

alexey

unread,
Jul 15, 2003, 2:29:26 PM7/15/03
to
How do I retrieve the array values?

I am using:
ManagementObjectSearcher

ManagementBaseObject

PropertyData

Classes to retrive data. everything works perfect for scalar data. But when
I check pd.IsArray property and find that it is array i have no way to
access the values of the array? Casting to Array doesn't sem to work in C#.

What do i do?

Thanks

Alexey

Andy Cheung [MSFT]

unread,
Jul 16, 2003, 12:45:23 AM7/16/03
to
You can try to cast the PropertyData value to IEnumerable and then enumerate
the collection. e.g.
IEnumerable enumerable = managementObject["PropertyNameHere"] as
IEnumerable;
if (enumerable != null)
{
foreach(object propertyValue in enumerable)
{
Console.WriteLine(propertyValue);
}
}


--
Andy Cheung
Microsoft WMI Test Engineer
This posting is provided "As Is" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"alexey" <ale...@intuitivelabs.com> wrote in message
news:OomwU8vS...@TK2MSFTNGP12.phx.gbl...

0 new messages