typeof(Nullable<>)
public static bool IsNullableType(Type t)
{
return t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>);
}
I was using this to check whether Lambda Expressioin parameters are nullable.
There’s no need to do this yourself – you can just use
Nullable.GetUnderlyingTypewhich returnsNothing/nullif the type you pass it isn’t nullable:(But if you really need an open generic type, then
GetType(Nullable(Of))will work. If you need multiple type parameters, just comma-separate them, e.g.GetType(Dictionary(Of ,)).)