IEnumerable<T> is an open generic type. This is not a real type; it's just a function that builds specific (private) generic types of type IEnumerable<int> .
IEnumerable<int> is the interface; it is impossible to have an instance of the interface.
The iterator function actually returns an instance of a hidden compiler-generated class that implements IEnumerable<int> ; what you see from GetType() .
You want to find a generic type of an implementation type of type IEnumerable<T> :
em.GetType().GetInterface("System.Collections.Generic.IEnumerable`1") .GetGenericArguments()[0]
SLaks source share