public class MyList : List<MyClass>
How can I get the type MyClass through reflection if I have an object that contains an instance of MyList? The list can be empty, so I can’t do something like myList[0].GetType().
p.s. I can’t just stop using MyList and directly use the generic List instead (the situation is a bit more complicated, and there are reasons for “hiding” the generic argument), so I can’t pick up MyClass through GetGenericArguments().
I use
IList<T>instead of list. This is more generic. However, there is also the change of a type implementing multipleILis<T>versions (such asIList<string>andIList<int>).