Remarks
A type is said to be nullable if it can be assigned a value or can be assigned null
, which means the type has no value whatsoever. By default, all reference types, such as , are nullable, but all value types, such as , are not.
In C# and Visual Basic, you mark a value type as nullable by using the ?
notation after the value type. For example, int?
in C# or Integer?
in Visual Basic declares an integer value type that can be assigned null
.
The structure supports using only a value type as a nullable type because reference types are nullable by design.
The class provides complementary support for the structure. The class supports obtaining the underlying type of a nullable type, and comparison and equality operations on pairs of nullable types whose underlying value type does not support generic comparison and equality operations.