title: C# XmlSerializer Order decorator issue with inherited class
body: <p>This code is not giving the proposed result, as the order of the elements does not appear as specified:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Xml.Serialization;
  
  namespace XmlSerializeTest
  {
      class Program
      {
          static void Main(string[] args) {
              SubClass test = new SubClass();
              test.A = "A";
              test.B = "B";
              test.C = "C";
  
              XmlSerializer SerializerObj = new XmlSerializer(typeof(SubClass));
              TextWriter WriteFileStream = new StreamWriter(@"C:\test.xml");
              SerializerObj.Serialize(WriteFileStream, test);
              WriteFileStream.Close();
          }
      }
  
      [Serializable()]
      public class BaseClass {
          [XmlElement(Order = 2)]
          public string B { get; set; }
      } 
  
      [Serializable()]
      public class SubClass : BaseClass {
          [XmlElement(Order = 1)]
          public string A { get; set; }
          [XmlElement(Order = 3)]
          public string C { get; set; }
      } 
  }
  </code></pre>
  
  <p>It gives this result:</p>
  
  <pre><code>&lt;BaseClass&gt;
    &lt;B&gt;B&lt;/B&gt;
    &lt;A&gt;A&lt;/A&gt;
    &lt;C&gt;C&lt;/C&gt;
  &lt;/BaseClass&gt;
  </code></pre>
  
  <p>What could be done to get the correct order (A,B,C)?</p>
  
  <p>I have tried these alternatives as well: </p>
  
  <pre><code>new XmlSerializer(typeof(BaseClass), new [] {typeof(SubClass)});
  new XmlSerializer(typeof(SubClass), new [] {typeof(BaseClass)});
  </code></pre>