06 연산자

vencott·2021년 6월 2일
0

C#

목록 보기
6/32

기본 연산자는 다른 프로그래밍 언어와 유사하다

?? 연산자

Null-coalescing operator, C# 3.0 이상에서 지원

A ?? B

A의 값이 NULL인경우 ?? B를 리턴하고, 아니라면 A를 리턴

A가 Nullable 타입일때만 ?? 연산자가 지원된다

int? i = null;
i = i ?? 0;

string s = null;
s = s ?? string.Empty;

출처: http://www.csharpstudy.com/

profile
Backend Developer

0개의 댓글