mardi 15 mars 2016

How do I get the type of a member through reflection?

I need to read the value of a member (it may be a field or a property) whose name is passed to my method. This is how I retrieve the MemberInfo:

MemberInfo member = itemType.GetField(fieldName) as MemberInfo ?? itemType.GetProperty(fieldName) as MemberInfo;

Next, I'd like to check the type of the member (field/property) that has been found. What's the correct way to do this?





Aucun commentaire:

Enregistrer un commentaire