I'm curious how to check if given type is closed version of open type. For instance
public bool IsGenericList(Type source)
{
return (source.IsGenericType &&
/*here goes the manipulation on source type*/ == typeof(List<>));
}
I'm curious how to check if given type is closed version of open type. For instance
public bool IsGenericList(Type source)
{
return (source.IsGenericType &&
/*here goes the manipulation on source type*/ == typeof(List<>));
}
Try Type.GetGenericTypeDefinition
:
public bool IsGenericList(Type source)
{
return source.IsGenericType &&
source.GetGenericTypeDefinition() == typeof(List<>);
}