2 ms·
Null coalescence in C#. Reference types must be checked before trying to access their members. So you’ll see a lot of: if (mything != null && mything.User != n
by mwsherman 15y ago
Null coalescence in C#. Reference types must be checked before trying to access their members. So you’ll see a lot of:
if (mything != null && mything.User != null) {
Do.Something(mything.User.Name);
}
I’d like to write:
Do.Something(mything?.User?.Name);
It’s syntactic sugar, but would greatly improve readability, and a compiler could do it with no change to the runtime.