I want to determine if a generic object type (\"T\") method type parameter is a collection type. I would typically be sending T through as a Generic.List but it could be any co
In order to get the actual type of T at runtime, you can use the typeof(T) expression. From there the normal type comparison operators will do the trick
bool isEnumerable = typeof(IEnumerable).IsAssignableFrom(typeof(T));
Full Code Sample:
static bool Foo()
{
return typeof(IEnumerable).IsAssignableFrom(typeof(T));
}
Foo>(); // true
Foo(); // false