Reputation: 37
I'm writing a console application that displays all the user's license information in my tenant. When I tried to print, It's printing like "System.Collections.Generic.List`1[Microsoft.Online.Administration.UserLicense]". How to parse data from it using c#?
foreach (PSObject result in PS.Invoke())
{
foreach (var member in result.Members)
{
if (member.Name == "Licenses")
{
Console.WriteLine(member.Value);
}
};
}
Upvotes: 0
Views: 945
Reputation: 174825
List`1
(or List<T>
if you will) implements IEnumerable
, so an extra foreach
loop to iterate through the values will do:
foreach (PSObject result in PS.Invoke())
{
foreach (var member in result.Members)
{
if (member.Name == "Licenses")
{
foreach (var license in member.Value)
{
// license is now an individual `UserLicense` object
}
}
}
}
Upvotes: 1