title: Check if object instantiated
body: <p>I have an object which is made of many other objects! I am trying to find the value of of one of the properties (an enum) but can't.</p>
  
  <p>Now, normally if I want to check if an object is null I can do</p>
  
  <pre><code>if (object == null) 
  </code></pre>
  
  <p>but this results in the same error.</p>
  
  <p>I tried</p>
  
  <pre><code>if (object.Equals(null)) and the same error.
  </code></pre>
  
  <p>The error message I'm getting is objectName threw exception:  System.NullReferenceException: Object reference not set to an instance of an object.. </p>
  
  <p>I'm trying to determine if my object is instantiated or not. Now, I can stick this into a try catch, if it errors then I know it's not, but to me this feels very wrong (although I may not have a choice).</p>
  
  <p>The other problem I have is this project isn't mine and is a black box to everyone and so I can't make any changes to the original object! This means, all I have is what I have got, an object which may or may not be instantiated and I need a way of telling.</p>
  
  <p>Other than the try catch, do I have any other options?</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>So, the object is</p>
  
  <pre><code>public partial class SaveBundleResponse 
  {
      SaveBundleResponseHeader header;
  }
  
  public partial class SaveBundleResponseHeader 
  {      
          private SaveBundleResponseHeaderStatus status;
  }
  
  public enum SaveBundleResponseHeaderStatus 
  {        
          Success, Fail, OK, OtherStates
  }
  </code></pre>
  
  <p>So the SaveBundleResponse is created initially, the instance is then passed through a 'workflow' style environment and each property becomes 'populated/updated' etc as it goes deeper into the workflow. However, in a few situations, the enum is never set.</p>
  
  <p>The problem is, I need to know the value of the enum (or if it is null).</p>
  
  <p>The code I am trying to use is</p>
  
  <pre><code>        if (saveBundleResponse.Header.Status // what ever happens, it fails at this point as Status is not initiated.
  </code></pre>