Is it possible to check the type of a generic type without using any generic parameters?
For example, I would like to do something similar to the following (real type names have been changed to protect the innocent):
var list = new List<SomeType>();
...
if (list is List)
{
Console.WriteLine("That is a generic list!");
}
In the above code, the following error is generated:
Using the generic type 'System.Collections.Generic.List<T>' requires 1 type arguments
Is there any way around this? Preferably, something short and something that will work with types that DO NOT have common parameters (that is, "if myString is a List").
source
share