title: XmlSerializer serializing sub objects
body: <p>How do you serialize the following</p>
  
  <pre><code>[XmlRoot("response")]
  public class MyCollection&lt;T&gt;
  {
      [XmlElement("person", Type = typeof(Person))]
      public List&lt;T&gt; entry;
      public int startIndex;
  }
  </code></pre>
  
  <p>where T can be a class like </p>
  
  <pre><code>public class Person
  {
      public string name;
  }
  </code></pre>
  
  <p>into</p>
  
  <pre><code>&lt;response&gt;
    &lt;startIndex&gt;1&lt;/startIndex&gt;
    &lt;entry&gt;
        &lt;person&gt;
           &lt;name&gt;meeee&lt;/name&gt;
        &lt;/person&gt;
    &lt;/entry&gt;
    &lt;entry&gt;
        &lt;person&gt;
           &lt;name&gt;youuu&lt;/name&gt;
        &lt;/person&gt;
    &lt;/entry&gt;
  &lt;/response&gt;
  </code></pre>
  
  <p>I have been playing with [XmlArray], [XmlArrayItem], and [XmlElement] and I can't seem to get the right combination. Arrrgghhh.</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>[XmlArray("entry")]
  [XmlArrayItem("person", Type = typeof(Person))]
  public List&lt;T&gt; entry;
  </code></pre>
  
  <p>gives me</p>
  
  <pre><code>&lt;entry&gt;&lt;person&gt;&lt;/person&gt;&lt;person&gt;&lt;/person&gt;&lt;/entry&gt;
  
  
  [XmlElement("person", Type = typeof(Person))]
  public List&lt;T&gt; entry;
  </code></pre>
  
  <p>gives me</p>
  
  <pre><code>&lt;person&gt;&lt;/person&gt;&lt;person&gt;&lt;/person&gt;
  </code></pre>