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?
Clarification Collection type means any type that can store or manage multiple members (the exact number of memberitems doesn't matter). One may also call it a container type. E.g. Collection, List, Array, Dictionary, ...
IEnumarable however isn't a good criteria to seperate collection types from non collection types. String for example implements IEnumerable because it provides an array of char. But String isn't a collection type.
My concern is, treating types like String the wrong way - as a collection. In case of string I would end up reading the array of char, but I really wanted to read the string itself.
In case of a real collection type, e.g. List<int>
I do want to read every member. In this example every integer value.
There is no need to modify the values!