C#
long? 형식은 nullable 가능하게 됨 ( null값 허용 )
saltdoll
2017. 9. 29. 09:00
반응형
함수명(long? id) 이렇게 쓰일때가 있다.
long?의 의미는
long은 Int64와 동일하며
?의 의미는 nullable (널값을 허용한다는 의미)
long
is the same as Int64
The ?
means it is nullable
A nullable type can represent the normal range of values for its underlying value type, plus an additional null value
Nullable example:
int? num = null;
if (num.HasValue == true)
{
System.Console.WriteLine("num = " + num.Value);
}
else
{
System.Console.WriteLine("num = Null");
}
This allows you to actually check for a null
value instead of trying to assign an arbitrary value to something to check to see if something failed.
I actually wrote a blog post about this here.
출처: https://stackoverflow.com/questions/3893143/what-is-long-data-type
반응형