title: WCF: Object Reference Not Set To Instance Of a an Object
body: <p>I have a CibilResponse Class that has properties that are of class type (TUEF class). I am trying to assign value to <code>CibilEnquiryEnq.Tuef.Version</code> but i am getting null reference error. Before you mark this question as duplicate let me mention that I have read some of the similar questions and their answers on SO and post which I have initialized tuef in the constructor as you can see in my code. Can you please point out if you can what is it that I am doing wrong?</p>
  
  <p><strong>ICIBIL.cs</strong></p>
  
  <pre><code>[ServiceContract]
  public interface ICIBIL
  {
  
      [OperationContract]
      string InsertCibil(CibilResponse cibilResponse);
  
  
      [OperationContract]
      string GenerateEnquiry(CibilEnquiry testObj);
  
  
  }
  
  [DataContract]
  public class CibilResponse
  {
      [DataMember]
      public string ResponseString { get; set; }
      [DataMember]
      public string Business { get; set; }
      [DataMember]
      public string MkrId { get; set; }
  }
  
  
  [DataContract]
  public class CibilEnquiry
  {
      [DataMember]
      public TUEF Tuef { get; set; }   
  
      public CibilEnquiry()
      {
          this.Tuef = new TUEF();
      }
  
  }
  
  
      [DataContract]
      public class TUEF
      {
          [DataMember]
          public string SegmentTag { get; set; }
          [DataMember]
          public string Version { get; set; }
          [DataMember]
          public string MemberReferenceNumber { get; set; }        
  
      }
  </code></pre>
  
  <p><strong>Appication :</strong></p>
  
  <pre><code>CibilWcfService.CIBIL obj = new CibilWcfService.CIBIL();
  CibilWcfService.CibilEnquiry CibilEnquiryEnq = new CibilWcfService.CibilEnquiry();
  CibilEnquiryEnq.Tuef.Version = "123";// null reference error here
  string res = obj.GenerateEnquiry(CibilEnquiryEnq);
  </code></pre>