I suppose method call chain below.
void DoSomething() { ObjectA a = CreateA(); if (a != null) { a.Foo(); } } ObjectA CreateA() {
Starting with C# 6.0 you can use Null-Conditional Operator, which lets you make null-checking implicitly:
var result = possiblyNull?.MethodThatCanReturnNull()?.SomeProperty;
This construct will produce a null result if any element in the chain produces null.
null