A while back, I emailed Microsoft’s Visual Studio support team, and suggested a possible addition for some future version of C# (or .NET in general), doing what I call Cascading Null Checking. Basically, the idea is that instead of writing this:
int zipcode = 0;
if (person != null && person.Address != null && person.Address.ZipCode != null)
zipcode = person.Address.ZipCode;
You’d be able to write this:
int? zipcode = person?Address?ZipCode;
I don’t know exactly impressed I was with their answer, but I’m glad that they emailed back. Apparently, it’s something that they’ve wanted to do for a while, but are trying to figure out how to properly deal with the meaning of each piece of the statement. You can read their response in full here.