Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PropertyInfo.GetValue Question
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01473610
Message ID:
01473682
Views:
32
>I have an XML file deserialized into SuperCollectionClass. I'm trying to use reflection to look at it:
>
>
>PropertyInfo[] properties = typeof(SuperCollectionClass).GetProperties();
>
>foreach (var property in properties)
>{
>    string TableName = property.Name;
>
>    var Value = property.GetValue(, null);
>}
>
>
>
>What is the first param that getValue expects? IntelliSense says object obj which tells me nothing. I don't get what it's looking for.

An instance of SuperCollectionClass (or a class derived from it). e.g;
SuperCollectionClass sc = new SuperCollectionClass();
            // You could use this instance instead :
            PropertyInfo[] p2 = sc.GetType().GetProperties();

            PropertyInfo[] properties = typeof(SuperCollectionClass).GetProperties();
            foreach (var property in properties)
            {
                string TableName = property.Name;
                var v = property.GetValue(sc, null);
            }
Previous
Reply
Map
View

Click here to load this message in the networking platform