Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

For me

[Unity] 5) Nullable 본문

Unity/이론

[Unity] 5) Nullable

GiveZero 2023. 3. 1. 00:11

Nullable

개념

0이 아닌 비어있는 변수 , null 상태를 가질 수 있는 변수

int, float를 초기화 할 때 null 사용 불가능 → -1, 0 등 숫자로 초기화

 

Nullable 변수 선언

int? intValue = null;
float? floatValue = null;
string? stringValue = null;

데이터가 비어있을 때 Value를 호출하면 InvaildOperationException 예외 출력

 

HasValue와 Value

HasValue : 변수가 가지고 있는지 가지고 있지 않는지 (true, false)

Value : 변수에 담겨 있는 값

'Unity > 이론' 카테고리의 다른 글

[Unity] 7) Action<T>, Func<T,T>  (0) 2023.03.03
[Unity] 6) Addressable  (0) 2023.03.03
[Unity] 4) Reflection 과 Attribute  (0) 2023.02.28
[Unity] 3) Exception  (0) 2023.02.28
[Unity] 2) Delegate 와 Event  (0) 2023.02.28