.NET: How to determine if a type is null?

Possible duplicate:
How to check if an object is null?

I have a System.Type object that can be Nullable<T>. How can I detect this at runtime?

Note: At this point, I don't care what T is, I just need to know if it is Nullable.

+3
source share
1 answer

Possible duplicate:

How to check if an object is valid?

if not..

bool IsNullableType(Type theType)
{
    return (theType.IsGenericType && 
    theType.GetGenericTypeDefinition().Equals(typeof(Nullable<>)));
}
+11
source

Source: https://habr.com/ru/post/1779967/


All Articles