title: XmlSerializer serialize generic List of interface
body: <p>I'm trying to use the XmlSerializer to persist a List(T) where T is an interface. The serializer does not like interfaces. I'm curious if there is a simple way to serialize a list of heterogeneous objects easily with XmlSerializer. Here's what I'm going for:</p>
  
  <pre><code>    public interface IAnimal
      {
          int Age();
      }
      public class Dog : IAnimal
      {
          public int Age()
          {
              return 1;
          }
      }
      public class Cat : IAnimal
      {
          public int Age()
          {
              return 1;
          }
      }
  
      private void button1_Click(object sender, RoutedEventArgs e)
      {
          var animals = new List&lt;IAnimal&gt;
          {
              new Dog(),
              new Cat()
          };
  
          var x = new XmlSerializer(animals.GetType());
          var b = new StringBuilder();
          var w = XmlTextWriter.Create(b, new XmlWriterSettings { NewLineChars = "\r\n", Indent = true });
          //FAIL - cannot serialize interface. Does easy way to do this exist?
          x.Serialize(w, animals);
          var s = b.ToString();    
      }
  </code></pre>