The Null Value in C # cannot be assigned to the value type. The value type here includes struct. The reason is that the value type cannot contain references. null, as a "none" reference, cannot be referenced by the value type. In actual application, this will cause some problems. If an int type cannot determine its value. An empty type is required.
The value type variable that can be assigned a null value. An empty type based on the reference type cannot be created. (The reference type supports null values .).
Int? : Indicates an empty type, which is a special value type. Its value can be null.
It is used to assign null to the variable (INT type) when setting the initial value, instead of 0.
Int ?? : Used to determine and assign values. First, judge whether the current variable is null. If yes, you can activate a new value. Otherwise, skip
Void main () {system. nullable <int> I = NULL; console. writeline (I. hasvalue); console. writeline (I); var T = I ?? 0; console. writeline (t); var S = (Int ?) NULL; // system. nullable <t> can be abbreviated as t ?, Console. writeline (s); console. writeline (I. GetType (); // exception console. writeline (I. Value); // exception}