lenelex.com
Home
Quizzes
Games
Register
Log in
Question 1 of 20
Which of the following expressions is equivalent to the code below?
//Assume the list has a value of null. int x = 0; if (list != null) { x = list.Count; }
A. int x = list.Count ?? 0;
B. int x = list?.Count;
C. int x = list?.Count ?? 0;
D. int x = (list.Count != null) ? (list.Count) : (0);
Links:
Null-conditional Operators
The Null-coalescing Operator