Once again one of those: \"Is there an easier built-in way of doing things instead of my helper method?\"
So it\'s easy to get the underlying type from a nullable type,
Here is the code I use:
Type GetNullableType(Type type) {
// Use Nullable.GetUnderlyingType() to remove the Nullable wrapper if type is already nullable.
type = Nullable.GetUnderlyingType(type) ?? type; // avoid type becoming null
if (type.IsValueType)
return typeof(Nullable<>).MakeGenericType(type);
else
return type;
}