title: XML deserialization ignores properties out of alphabetical order
body: <p>I have small problem - XML deserialization completely ignores items, which are out of alphabetic order. In example object (description in end of question), <code>Birthday</code> node is after <code>FirstName</code> node, and it is ignored and assigned default value after deserialization. Same for any other types and names (I had node <code>CaseId</code> of <code>Guid</code> type after node <code>Patient</code> of <code>PatientInfo</code> type, and after deserialization it had default value).</p>
  
  <p>I'm serializing it in one application, using next code:</p>
  
  <pre><code>public static string SerializeToString(object data)
  {
      if (data == null) return null;
      XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
      ns.Add("", "");
  
      // what should the XmlWriter do?
      var settings = new XmlWriterSettings
      {
          OmitXmlDeclaration = true,
          NewLineChars = ""
      };
  
      using (var stringwriter = new System.IO.StringWriter())
      {
          // Use an XmlWriter to wrap the StringWriter
          using (var xmlWriter = XmlWriter.Create(stringwriter, settings))
          {
              var serializer = new XmlSerializer(data.GetType(), "");
              // serialize to the XmlWriter instance
              serializer.Serialize(xmlWriter, data, ns);
              return stringwriter.ToString();
          }
      }
  }
  </code></pre>
  
  <p>Such approach was used to get proper result as argument for WebMethod (full problem described <a href="https://stackoverflow.com/posts/34335238">here</a>). Results are something like this:</p>
  
  <blockquote>
    <p>&lt;PatientInfo>&lt;FirstName>Foo&lt;/FirstName>&lt;Birthday>2015-12-19T16:21:48.4009949+01:00&lt;/Birthday>&lt;RequestedClientID>00000000-0000-0000-0000-000000000000&lt;/RequestedClientID>00000000-0000-0000-0000-000000000000&lt;/patientId>&lt;/PatientInfo></p>
  </blockquote>
  
  <p>Also I'm deserializing it in another application in simple manner</p>
  
  <pre><code>public static T Deserialize&lt;T&gt;(string xmlText)
  {
      if (String.IsNullOrEmpty(xmlText)) return default(T);
      using (var stringReader = new StringReader(xmlText))
      {
          var serializer = new XmlSerializer(typeof(T));
          return (T)serializer.Deserialize(stringReader);
      }
  }
  </code></pre>
  
  <p>Example object:</p>
  
  <pre><code>[XmlRoot("PatientInfo")]
  public class PatientInfo
  {
      [XmlElement("FirstName")]
      public string FirstName { get; set; }
      [XmlElement("LastName")]
      public string LastName { get; set; }
      [XmlElement("SSN")]
      public string SSN { get; set; }
      [XmlElement("Birthday")]
      public DateTime? Birthday { get; set; }
      [XmlElement("RequestedClientID")]
      public Guid RequestedClientID { get; set; }
      [XmlElement("patientId")]
      public Guid patientId { get; set; }
  }
  </code></pre>
  
  <p>So, I'd like to have answer for one of two questions - 1) How can I adjust my serialization to have all items in alphabetical order? 2) How can I adjust my deserialization, so it won't ignore items out of alphabetical order?</p>
  
  <p>Any help is appreciated.</p>
  
  <p><strong>Update:</strong></p>
  
  <p>Just figured out, that deserialization method I'm using is not actually used at all in my problem, since I'm using serialized info as data with WebMethod, and it is deserialized with some internal mechanism of WCF.</p>