In C #?? What's the meaning of the distinction?
1. Nullable type modifier (? ):
A reference type can use a null reference to represent a value that does not exist, and a value type usually cannot be represented as empty.
For example: string str=null; is correct, int i=null; the compiler will error.
To make a value type nullable, you can use a nullable type, which is the nullable type modifier "? "To indicate that the representation is" T? "
for example: Int? Represents a nullable shape, DateTime? Represents a time that can be empty.
T? is actually an abbreviated form of system.nullable (generic structure), which means when you use T? When the compiler compiles the T? Compiled into a system.nullable form.
For example: int, after compiling is the form of system.nullable.
2. Ternary (operator) expression (?:) :
For example: X?y:z indicates that if the expression x is true, then Y is returned, and if X is False, Z is returned, which is a simple form of omitting if{}else{}.
3. Empty merge operator (??) :
used to define the default values for nullable types 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.
For example: a?? b When a is null, returns B,A if it is not null.
An empty merge operator is a right-associative operator, which is a combination of right-to-left operations. For example, "a??" B?? C "In the form of" a?? (b?? c) "calculation.
In C #?? And? What is the meaning of the distinction?