Null Operators
?? gives a default, ??= assigns if null and ?. avoids NullReferenceException.
Example
string? a = null;
string b = a ?? "default";
a ??= "set";
Console.WriteLine($"{b} {a} {a?.Length}");Exercise
Assign if null.
a "x"
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.