Skip to main content
Nullable Conversion 

Defines an explicit conversion of a Nullable instance to its underlying value.

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

public static explicit operator T (
	Nullable<T> value
static explicit operator T (
	Nullable<T> value
F# does not support this operator
Public Shared Narrowing Operator CType (
	value As Nullable(Of T)
) As T



A nullable value.

Return Value

Type: T

The value of the property for the value parameter.

This operator supports the explicit conversion of the current Nullable instance to type T, the type of . The syntax for such explicit conversions is language-dependent. You may also be able to perform the conversion by calling the ConvertChangeType method.

The operator enables code such as the following, which converts a Nullable(Of Int32) value to an Int32 value.

using System;

public class Example
   public static void Main()
       var nullInt = new Nullable<int>(172);
       // Convert with CInt conversion method.
       // Convert with Convert.ChangeType.
       Console.WriteLine(Convert.ChangeType(nullInt, typeof(int)));
// The example displays the following output:
//       172
//       172
Module Example
   Public Sub Main()
       Dim nullInt = New Nullable(Of Integer)(172)
       ' Convert with CInt conversion method.
       ' Convert with CType conversion method.
       Console.WriteLine(CType(nullInt, Integer))
       ' Convert with Convert.ChangeType.
       Console.WriteLine(Convert.ChangeType(nullInt, GetType(Integer)))
   End Sub
End Module
' The example displays the following output:
'       172
'       172
'       172
Universal Windows Platform
Available since 8
.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
Return to top