In C#, the expression a ?? b returns:
-
A
true if both a and b are null
-
B
a if it is not null, otherwise b
Correct answer
-
C
a and b combined into one string
-
D
b if it is not null, otherwise a
Correct answer
B. a if it is not null, otherwise b
12 views
Explanation
The null-coalescing operator (??) provides a fallback value, as in name ?? "Guest". The related ??= operator assigns only when the left side is null.
Reference
Asked in: NTS, Technical Interviews
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ