[C#] Nullable 형식


[C#] Nullable 형식

Nullable은 변수에 null값이 필요할 때 사용할 수 있다. Colored By Color Scripter 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace nullable_test { class Program { static void Main(string[] args) { //int a = null ; //error int? b = null; Console.WriteLine(b.HasValue); b = 5; if (b.HasValue) Console.WriteLine(b); } } } 위의 예시를 보면 int a = null일 경우 error가 되지만 int? b = null;은 사용이 된다...


#IT·컴퓨터

원문링크 : [C#] Nullable 형식