This (null-safe dereferencing) is what sometimes arises, and not; There is currently no accurate answer, except:
if(Object1 == null || Object1.Object2 == null || Object1.Object2.Object3 == null || Object1.Object2.Object3.Property == null)
You can do a little caching if you need (by entering variables), but it gets even uglier:
SomeType2 obj2; SomeType3 obj3; if(Object1 == null || (obj2 = Object1.Object2) == null || (obj3 = obj2.Object3) == null || obj3.Property == null)
In general, I would advise you to disagree with the above if you really do not want to name the property twice (because it works more than the property)
source share