?? Operator (C # reference ),
?? An operator is a null merge operator that defines the types that can be null values and the default values of reference types. If the left operand of this operator is not null, this operator returns the left operand; otherwise, the right operand is returned.
class NullCoalesce{ static int? GetNullableInt() { return null; } static string GetStringValue() { return null; } static void Main() { // ?? operator example. int? x = null; // y = x, unless x is null, in which case y = -1. int y = x ?? -1; // Assign i to return value of method, unless // return value is null, in which case assign // default value of int to i. int i = GetNullableInt() ?? default(int); string s = GetStringValue(); // ?? also works with reference types. // Display contents of s, unless s is null, // in which case display "Unspecified". Console.WriteLine(s ?? "Unspecified"); }}
Bitwise XOR operators in C Language
1: The "bitwise AND" Operator (&) is used if both of the corresponding binary bits are 1, The result value of this bits is 1 or 0. 0 & 0 = 0, 1 & 0 = 0, 1 & 1 = 1
2: The bitwise OR operator (|) is used if one of the two binary bits is 1, The result value of this bits is 1 or 0. 0 & 0 = 0, 1 & 0 = 0, 1 & 1 = 1
0, 1 & 0 = 1, 1 & 1 = 1
3: The "XOR" Operator (^) is used if two corresponding binary bits are of the same number, the result value of this bits is 1 or 0. 0 & 0 = 1, 1 & 0 = 0, 1 & 1 = 1
What is the condition operator in C?
Conditional operators (? :) It is the only three-object operator in C language, that is, it has three operation objects. The condition operator is in the form "? : "The expressions composed of them are called conditional expressions.
The conditional expression is in the following format:
Expression 1? Expression 2: expression 3
Example: (a> B )? A + B: a-B
Where, if a = 2, B = 1, then a> B is true, execute the expression a + B, and the calculation result is 3; but if a = 2, B = 3, if expression a> B is not true, execute the expression a-B and the result is-1.