title: Exception : Object reference not set to an instance of an object
body: <p>I am getting Object reference not set to an instance of an object. exception for the following code. I can prevent this by creating an instance of RequestDetail and then passing ObjectId ot that.</p>
  
  <p>But whats wrong with this code.</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          Request header = new Request();
          header.RequestDetail.ObjectId = "12343";
  
          RequestDetail rd = new RequestDetail();
          rd = header.RequestDetail;
  
          Console.WriteLine(rd.ObjectId);
      }
  }
  
  public class Request
  {
      public RequestDetail RequestDetail { get; set; }
  }
  public class RequestDetail
  {
      public string ObjectId { get; set; }
  }
  </code></pre>