mercredi 28 novembre 2018

C# identify only collection like datatypes by using reflection

I am using C# .Net 4.7.2

I want to analyse a type by using reflection. One part of the analysing is to identify the properties which are of any kind of collection. Such as Collection, List, Array, IEnumerable, etc.

I thought it would be easy and searched for types implementing IEnumerable. Well, seems to be not that easy. String for example implements IEnumrable as well, but is not a collection type.

Is there anything more, that I could use to assert, that the property is some kind of collection?





Aucun commentaire:

Enregistrer un commentaire