1. Nullable type modifier (? ): A reference type can use a null reference to represent a nonexistent value, and a value type usually cannot be represented as empty, for example: string str=null; int i=null; The compiler will make an error. For the value type to be nullable, the nullable type appears, and the nullable type uses the nullable type modifier? To indicate that the representation is T?. Example: Int? Represents a nullable shape, datetime, which is represented as a nullable time. T? is actually an abbreviated form of system.nullable<t> (generic structure), which means when you use T? At compile time, the compiler will put T? Compiled into the form of system.nullable<t>, for example: int, is the form of system.nullable<int> after compilation.
2, ternary (operator) expressions (?) :): For example int a=b>0?4:5 if B is greater than 0 returns a=4 otherwise a=5.
3. Empty merge operator (??). ): Defines 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. Example: A?? b, when a is null, returns a b,a when it is not empty to return a itself. 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.
This article is from the "Technical Experience sharing" blog, please be sure to keep this source http://yataigp.blog.51cto.com/4779773/1983948
In C # "? "There are three ways to use