lenelex.com
Home
Quizzes
Games
Register
Log in
Question 1 of 15
What is the output of the following code?
bool? a = null, b = true; var c = a ?? b ?? false; Console.WriteLine(c);
A. False
B. Error
C. True
D. Null
Using | and & operators with the bool? type
The results of these operators are listed in the following table: true & null = null; true | null = true; false & null = false; false | null = null; null & null = null; null | null = null.
The null-coalescing operator (??)
The null-coalescing operator has the following form: first_operand ?? second_operand; The operator returns the first_operand if it is not null; otherwise, it returns the second_operand.
Links:
Boolean Data Type
Using Nullable Types