Tag Archive for nullable

Nullable Types Summary

Nullable types (supported from .NET 2.0) are instances of the System.Nullable<T> struct. A nullable type can represent the correct range of values for its underlying value type, plus an additional null value.

Nullable types are declared in one of two ways:

  • System.Nullable<T> variable

-or-

  • T? variable

The ability to assign null to numeric and Boolean types is especially useful when you are dealing with databases and other data types that contain elements that may not be assigned a value. For example, a Boolean field in a database can store the values true or false, or it may be undefined. Yes, the nullable type modifier enables C# to create value-type variables that indicate an undefined value.

T is the underlying type of the nullable type. T can be any value type including struct; it cannot be a reference type. Reference types already support the null value.

Read more