Nullable Class
Collapse the table of content
Expand the table of content

Nullable Class


Supports a value type that can be assigned null. This class cannot be inherited.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Public NotInheritable Class Nullable

System_CAPS_pubmethodSystem_CAPS_staticCompare(Of T)(Nullable(Of T), Nullable(Of T))

Compares the relative values of two Nullable(Of T) objects.

System_CAPS_pubmethodSystem_CAPS_staticEquals(Of T)(Nullable(Of T), Nullable(Of T))

Indicates whether two specified Nullable(Of T) objects are equal.


Returns the underlying type argument of the specified nullable type.

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 String, are nullable, but all value types, such as Int32, 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 Nullable class provides complementary support for the Nullable(Of T) structure. The Nullable 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.

When a nullable type is boxed, the common language runtime automatically boxes the underlying value of the Nullable(Of T) object, not the Nullable(Of T) object itself. That is, if the HasValue property is true, the contents of the Value property is boxed. If the HasValue property is false, null is boxed. When the underlying value of a nullable type is unboxed, the common language runtime creates a new Nullable(Of T) structure initialized to the underlying value.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft