Nullable<T>.Explicit(Nullable<T> to T) 연산자

정의

Nullable<T> 인스턴스의 명시적 변환을 해당 내부 값으로 정의합니다.

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

매개 변수

value
Nullable<T>

nullable 값입니다.

반환

T

value 매개 변수의 Value 속성 값입니다.

예제

연산자는 Explicit 값을 값 Int32 으로 변환 Nullable(Of Int32) 하는 다음과 같은 코드를 사용하도록 설정합니다.

using System;

public class Example
{
   public static void Main()
   {
       var nullInt = new Nullable<int>(172);
       // Convert with CInt conversion method.
       Console.WriteLine((int)nullInt);
       // Convert with Convert.ChangeType.
       Console.WriteLine(Convert.ChangeType(nullInt, typeof(int)));
   }
}
// The example displays the following output:
//       172
//       172
open System

let nullInt = Nullable 172
// Convert with int conversion function.
printfn $"{int nullInt}"
// Convert with Convert.ChangeType.
printfn $"{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.
       Console.WriteLine(CInt(nullInt))
       ' 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

설명

이 연산자는 현재 Nullable<T> 인스턴스가 형식 T인 형식으로의 명시적 변환을 Value지원합니다. 이러한 명시적 변환에 대한 구문은 언어에 따라 다릅니다. 메서드를 호출 Convert.ChangeType 하여 변환을 수행할 수도 있습니다.

이 연산자에 대 한 해당 메서드는 Nullable<T>.Value

적용 대상