Redigeeri

Jagamisviis:


Nullable<T>.Implicit(T to Nullable<T>) Operator

Definition

Creates a new Nullable<T> object initialized to a specified value.

public:
 static operator Nullable<T>(T value);
public static implicit operator T? (T value);
static member op_Implicit : 'T -> Nullable<'T (requires 'T : struct)>
Public Shared Widening Operator CType (value As T) As Nullable(Of T)

Parameters

value
T

A value type.

Returns

A Nullable<T> object whose Value property is initialized with the value parameter.

Remarks

The Value property of the new Nullable<T> value is initialized to the value parameter and the HasValue property is initialized to true.

The equivalent method for this operator is Nullable<T>.Nullable<T>(T)

Note

In C# and Visual Basic, an implicit conversion from T to Nullable<T> does not invoke this operator because these languages have special rules for the conversion. This operator is provided for the benefit of languages that do not have such special rules.

Note

In C# and Visual Basic, an implicit conversion from a null or Nothing literal to Nullable<T> produces a Nullable<T> value whose HasValue property is initialized to false. The conversion occurs at compile time in these languages and does not invoke any operator.

Applies to