How to determine whether a type is an instance of some generic type without knowing T?
For example, given a type, here’s how to find out whether it’s a nullable type.
// is myType nullable? bool isNullable = myType.IsGenericType && (myType.GetGenericTypeDefinition() == typeof(Nullable<>));
Trackbacks
Use this link to trackback from your own site.



This would fail for typeof(Nullable)
Ah, that would be because System.Nullable isn’t nullable :-)