title: C# Xml Serializing List<T> descendant with Xml Attribute
body: <p>Morning Guys,</p>
  
  <p>I have a collection that descends from List and has a public property. The Xml serializer does not pick up my proeprty. The list items serialize fine. I have tried the XmlAttribute attribute to no avail. Do you guys have a solution? </p>
  
  <pre><code>    public partial class MainWindow : Window
  {
      public MainWindow()
      {
          InitializeComponent();
      }
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          var people = new PersonCollection
          {
              new Person { FirstName="Sue", Age=17 },
              new Person { FirstName="Joe", Age=21 }
          };
          people.FavoritePerson = "Sue";
  
          var x = new XmlSerializer(people.GetType());
          var b = new StringBuilder();
          var w = XmlTextWriter.Create(b, new XmlWriterSettings { NewLineChars = "\r\n", Indent = true });
          x.Serialize(w, people);
          var s = b.ToString();
      }
  }
  
  [XmlRoot(ElementName="People")]
  public class PersonCollection : List&lt;Person&gt;
  {
      //DOES NOT WORK! ARGHHH
      [XmlAttribute]
      public string FavoritePerson { get; set; }    
  }
  
  public class Person
  {
      [XmlAttribute]
      public string FirstName { get; set; }
      [XmlAttribute]
      public int Age { get; set; }
  }
  </code></pre>
  
  <p>I'm getting the following xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
          &lt;People xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
            &lt;Person FirstName="Sue" Age="17" /&gt;
            &lt;Person FirstName="Joe" Age="21" /&gt;
          &lt;/People&gt;
  </code></pre>
  
  <p>I would like to get this </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt;
          &lt;People FavoritePerson="Sue" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
            &lt;Person FirstName="Sue" Age="17" /&gt;
            &lt;Person FirstName="Joe" Age="21" /&gt;
          &lt;/People&gt;
  </code></pre>