Class Member Operators Null Conditional Member Access
suggest changevar zipcode = myEmployee?.Address?.ZipCode;
//returns null if the left operand is null.
//the above is the equivalent of:
var zipcode = (string)null;
if (myEmployee != null && myEmployee.Address != null) {
zipcode = myEmployee.Address.ZipCode;
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents