title: Ignore NullReferenceException when reading object properties
body: <p>Is there any way to direct C# to ignore <code>NullReferenceException</code> (or any specific exception for that matter) for a set of statements. 
  This is useful when trying to read properties from a deserialized object that may contain many null objects in it.
  Having a helper method to check for null could be one way but I'm looking for something close to 'On Error Resume Next' (from VB) at a block of statement level.</p>
  
  <p>EDIT:Try-Catch will skip the succeeding statements on exception</p>
  
  <pre><code>try
  {
     stmt 1;// NullReferenceException here, will jump to catch - skipping stmt2 and stmt 3
     stmt 2;
     stmt 3;
  }
  catch (NullReferenceException) { }
  </code></pre>
  
  <p>For Example: I'm deserializing an XML message to an object and then try to access a property like</p>
  
  <pre><code>Message.instance[0].prop1.prop2.ID
  </code></pre>
  
  <p>now prop2 could be a null object (because it doesn't exists in XML Message - an optional element in XSD). right now I need to check for null for each element in the hierarchy before accessing the leaf element. i.e I've to check if instance[0], prop1, prop2 are not null, before accessing 'ID'.</p>
  
  <p>Is there a better way that avoids null-checking for each element in the hierarchy?</p>