System.Nullable<T>.GetValueOrDefault Method

Returns the value of the current instance, or if it has none, returns the default value for the type T.

Syntax

public T GetValueOrDefault ()

Returns

A value of type T, which is either the value of the current instance, or if it has none, the default value for the type T (i.e., all-bits-zero).

Remarks

Note: Nullable<T>.GetValueOrDefault (T) allows a value other than the default value to be returned if the current instance contains no value.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0