Be aware that this language feature is only available in C# 6 and later.
It's effectively the equivalent of:
x == null ? null
: x.y == null ? null
: x.y.z
In other words, it's a "safe" way to do x.y.z
, where any of the properties along the way might be null.
Also related is the null coalescing operator (??), which provides values to substitute for null
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…