title: Deserialize wcf xml response using datacontractserializer C#
body: <p>In our project, we are getting response from wcf service in xml format which we want to deserialize using datacontract serializer.</p>
  
  <p>Below is the xml response.</p>
  
  <pre><code>&lt;ArrayOfCustomerData xmlns="http://schemas.datacontract.org/2004/07/PACRM.QCT"&gt;
  &lt;CustomerData&gt;
  &lt;AccountID&gt;String content&lt;/AccountID&gt;
  &lt;AccountName1&gt;String content&lt;/AccountName1&gt;     
  &lt;/CustomerData&gt;
  &lt;CustomerData&gt;
  &lt;AccountID&gt;String content&lt;/AccountID&gt;
  &lt;AccountName1&gt;String content&lt;/AccountName1&gt;      
  &lt;/CustomerData&gt;  
  &lt;/ArrayOfCustomerData&gt;
  </code></pre>
  
  <p>We have written the following DataContract class to deserialize the xml.</p>
  
  <pre><code>[DataContract]
  public class ArrayOfCustomerData
  {
      [DataMember(Name="CustomerData")]
      public CustomerData[] customerData { get; set; }
  }
  
  [DataContract]
  public class CustomerData
  {
  [DataMember(IsRequired = true, Name = "AccountID")]
      public string new_AccountID { get; set; }
  
      [DataMember(IsRequired = true, Name = "AccountName1")]
      public string new_accountname1 { get; set; }
   }
  </code></pre>
  
  <p>C# code for deserialization is given below.</p>
  
  <pre><code> DataContractSerializer dcs = new DataContractSerializer(typeof(ArrayOfCustomerData));
          ArrayOfCustomerData data=new ArrayOfCustomerData();
          using (var stream = new StreamReader(response.GetResponseStream()))
          {
             var text=stream.ReadToEnd();
             MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(text));
             XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateTextWriter(ms, Encoding.UTF8);
              dcs.WriteObject(xdw, data);
          }
  </code></pre>
  
  <p>when i check the data.cusotmerData, it is returning null.
  Can anyone please provide solution for this issue? Thanks!</p>