title: Checking for null in an object hierarchy
body: <p>I have a large C# (3.0) object structure originating from a deserialized XML document. I need to know whether a variable deep in the hierarchy is null. The way I do this now is to check every parent object on the way down for null, but this leads to a long repetition of if statements.</p>
  
  <p>I am trying to avoid expensive try-catch blocks.</p>
  
  <p>Is there a smarter way to do this?</p>
  
  <p><strong>edit:</strong>
  For example after a deserialization of an XML application form into an object hierarchy structure there could potentially be a salary value under</p>
  
  <pre><code>applicationForm.employeeInfo.workingConditions.salary
  </code></pre>
  
  <p>but to find out safely I have to write something like</p>
  
  <pre><code>if (applicationForm.employeeInfo != null)
    if (applicationForm.employeeInfo.workingConditions != null)
      if (applicationForm.employeeInfo.workingConditions.salary != null)
  </code></pre>
  
  <p>because simply using the latter if-statement will of course fail if one of the parent objects is null.</p>
  
  <p>So I am looking for any smarter way to handle this situation.</p>