Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
PropertyInfo.GetValue Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01473610
Message ID:
01473682
Vues:
31
>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);
            }
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform