Only reference types can actually contain a null reference; special case Nullable<T> - all syntactic sugar; the resulting value is not really null (since Nullable<T> also a value type, so it cannot contain a null reference), it is just Nullable<T> with default(T) as its value and HasValue = false .
So it depends on what you ask.
If you are trying to determine if a type is suitable for assigning code in a < null literal ( Nothing in VB.NET), then this:
- All reference types
Nullable<T>
If you are trying to determine if a type is suitable for maintaining a null reference bona-fide, then this
Regarding the use of reflection to check for a specific type at runtime, the IsValueType check should be sufficient to get what you need, even if it is the first (just add special code in your code for Nullable<T> ).
source share