title: Handling null objects when calling methods
body: <p>I have been looking around finding the best possible option for handling null objects in calling a method (or method chain).</p>
  
  <p>It is our common practice to check with if condition: </p>
  
  <pre><code>if ( customObject != null ) {
      customObject.callMe();
  }
  </code></pre>
  
  <p>Which can be further improved by using extension methods:</p>
  
  <pre><code>Program customObject = null;
  if (customObject.NotNull()) {
      customObject.CallMe();
  }
  
  public static bool NotNull(this object o) {
      return o == null;
  }
  </code></pre>
  
  <p>PLEASE NOTE:  I normally ignore ! from my programming practice. Hence it is wise to say that for me extension methods are good to go.</p>
  
  <p>However, it becomes very complicated in dealing with when the Method chain is involved.</p>
  
  <pre><code>customObject.CallMe().CallMe2() ex... 
  </code></pre>
  
  <p>How you do think it can be handled in C#, so that the <code>CallMe</code> is called only if <code>customObject</code> is not null and <code>CallMe2</code> is called only if <code>CallMe</code> returns non null object.</p>
  
  <p>Of course I can use If conditions or ternary operator. However, I would want to know if vNext, C#5.0 has some thing to offer.</p>