Nullable 클래스
정의
null
에 할당할 수 있는 값 형식을 지원합니다.Supports a value type that can be assigned null
. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.
public ref class Nullable abstract sealed
public static class Nullable
[System.Runtime.InteropServices.ComVisible(true)]
public static class Nullable
type Nullable = class
[<System.Runtime.InteropServices.ComVisible(true)>]
type Nullable = class
Public Class Nullable
- 상속
-
Nullable
- 특성
설명
형식은 값을 할당 하거나 할당할 수 있는 경우 null을 허용 하는 것으로 간주 됩니다 null
. 즉, 형식에 값이 없음을 의미 합니다.A type is said to be nullable if it can be assigned a value or can be assigned null
, which means the type has no value whatsoever. 기본적으로와 같은 모든 참조 형식은 nullable 이지만 String 와 같은 모든 값 형식은 Int32 이 아닙니다.By default, all reference types, such as String, are nullable, but all value types, such as Int32, are not.
C # 및 Visual Basic에서는 값 형식 다음에 표기법을 사용 하 여 값 형식을 nullable로 표시 합니다 ?
.In C# and Visual Basic, you mark a value type as nullable by using the ?
notation after the value type. 예를 들어 int?
c #에서 또는 Integer?
Visual Basic는 할당할 수 있는 정수 값 형식을 선언 null
합니다.For example, int?
in C# or Integer?
in Visual Basic declares an integer value type that can be assigned null
.
Nullable클래스는 구조체를 보완 하도록 지원 합니다 Nullable<T> .The Nullable class provides complementary support for the Nullable<T> structure. Nullable클래스는 nullable 형식의 내부 형식 및 내부 값 형식이 제네릭 비교 및 같음 연산을 지원 하지 않는 nullable 형식 쌍에 대 한 비교 및 같음 연산을 지원 합니다.The Nullable class supports obtaining the underlying type of a nullable type, and comparison and equality operations on pairs of nullable types whose underlying value type does not support generic comparison and equality operations.
boxing 및 unboxingBoxing and Unboxing
Nullable 형식이 boxing 되 면 공용 언어 런타임에서는 개체 자체가 아니라 개체의 기본 값을 자동으로 boxing 합니다 Nullable<T> Nullable<T> .When a nullable type is boxed, the common language runtime automatically boxes the underlying value of the Nullable<T> object, not the Nullable<T> object itself. 즉, HasValue 속성이 이면 true
속성의 내용이 Value boxing 됩니다.That is, if the HasValue property is true
, the contents of the Value property is boxed.
HasValue
Nullable 형식의 속성이 인 경우 false
boxing 작업의 결과는 null
입니다.If the HasValue
property of a nullable type is false
, the result of the boxing operation is null
. Nullable 형식의 내부 값이 unboxing 되 면 공용 언어 런타임은 Nullable<T> 내부 값으로 초기화 된 새 구조체를 만듭니다.When the underlying value of a nullable type is unboxed, the common language runtime creates a new Nullable<T> structure initialized to the underlying value.
메서드
Compare<T>(Nullable<T>, Nullable<T>) |
두 Nullable<T> 개체의 상대 값을 비교합니다.Compares the relative values of two Nullable<T> objects. |
Equals<T>(Nullable<T>, Nullable<T>) |
지정된 두 Nullable<T> 개체가 같은지 여부를 나타냅니다.Indicates whether two specified Nullable<T> objects are equal. |
GetUnderlyingType(Type) |
지정된 nullable 형식의 내부 형식 인수를 반환합니다.Returns the underlying type argument of the specified nullable type. |