I’m looking for a nice way to handle a null reference in object hierarchy.
ie:
if(null == Object1.Object2.Object3.Property)
This example will throw a Null Reference exception if say Object2 is null.
In my case I don't care what is null, just that something is. I don't really want to put try/catches around each place that I want to do something like this, so I’ve been looking for an alternative.
I've experimented with the ?? operator but this makes for some ugly looking code after two levels.
Any ideas appreciated.