|
1. Conditional operator ?: For example: a == null ? null : a.x; This is the most common question mark? operator. Support: All versions C #
2. Shorthand int for null type definition?Null values in C# cannot be assigned to value types, if the value type needs to be set to empty, it must be defined with: System.Nullable<T> t, abbreviated as T? t For example, System.Nullable<int> total can be abbreviated as: int? total Support: >= .NET Framework 4.0
3. Null Merge Operator ??If the left operand of this operator is not null, this operator returns the left operand; Otherwise, the right operand is returned. For example: int x?; int y = x ?? -1; Support: >= .NET Framework 4.0
4.null conditional operator ?.Used to test for the presence of NULL before performing a member access (?.) or index (?[) operation. if(a != null) a.x(); Equivalent to a?. x(); Support >= C# 6.0
|