C # medium ?? And? What do they mean ?,
In C ?? And? What do they mean?
1. Can be empty type modifier (?) :
The reference type can use null reference to indicate a nonexistent value, while the value type cannot be null.
For example, string str = null; is correct, int I = null; the compiler reports an error.
To make the value type empty, you can use the void type, that is, the void type modifier "? "T? "
Example: int? It indicates an integer that can be null, DateTime? It indicates a time that can be empty.
T? It is actually the abbreviation form of System. Nullable (generic structure), which means when you use T? When the compiler compiles T? Compiled in the form of System. Nullable.
Example: int ?, After compilation, it is in the form of System. Nullable.
2. Ternary (operator) expression (? :):
Example: x? Y: z indicates that if expression x is true, return y. if expression x is false, return z, which is a simple form of if {} else {} omitted.
3. null merge operator (??) :
Defines the default values of the null and reference types. If the left operand of this operator is not null, this operator returns the left operand; otherwise, the right operand is returned.
Example: ?? B returns B if a is null, and a itself if a is not null.
The null merge operator is the right merge operator, that is, the Union from right to left during the operation. For example, "?? B ?? C ?? (B ?? C) "computing.