dimanche 23 avril 2017

c# IList element via reflection

I have a reflected property which is an IList. I have managed to use reflection to get the IList, but now I want to get a list of the properties of one of the elements (any element will do). The attempts I've made so far have failed.

The way I'd handled this before was to use .GetType().GetProperties, but if I try this:

 PropertyInfo[] pi = i[0].GetType().GetProperties();

It doesn't return anything. I know that the item in the list has some properties, but I just can't seem to get a list of them.

'i' is the IList and, if I run the program, it will tell me that it has one object (an instance of an NPC class). It will also give me the details using the intellisense. I just can't seem to get to these details using reflection. Please help!





Aucun commentaire:

Enregistrer un commentaire