分两种类型,value type and reference type.
By default, value type owns a default value. For integer, the default value is 0. The value type can't be null. Non nullable
But for reference types, included class, interface, delegates, arrays, objects, 这些引用类型可以=null。Nullable
? to make non nullable type nullable.
(typeName)to make nullable type non nullable(explicit conversion).
但是有时候值类型也需要等于空值呀,だから?を採用する。
bool IsMajor
bool? IsMajor=null
当一个是非的问题bool值表示用户的选择yes or no option,用户没有选择的时候
if(IsMajor==true){
}else
if(IsMajor==false) or if(!IsMajor.value){
}else{Console.WriteLine("User is not answer the que")}
?? Null coalescing operator
int? a=10;
int b=a??0; equals{
if(a==null){b=0;}else{b=a.Value; or b=(int)a;} //Direct Assignment will be fault. b=a
}
Double Question Mark