title: Serialize a list of objects inheriting from class A to xml, so the names of the elements in the xml are B,C,D
body: <p>Using <code>DataContractSerializer</code> I want to serialize a list of object that inherit from class A. Those objects are in different assembly  and let's say they are of class B, C and D. I have added the B,C and D to the known types of the data contract serializer. I was able to serialize the list, but the outcome of the serialization looks like this:</p>
  
  <pre><code>&lt;SerializedListObjects&gt;
     &lt;A i:type="B"&gt;
     &lt;A i:type="C"&gt;
  &lt;/SerializedListObjects&gt;
  </code></pre>
  
  <p>What I want is:</p>
  
  <pre><code>&lt;SerializedListObjects&gt;
     &lt;B&gt;
     &lt;C&gt;
  &lt;/SerializedListObjects&gt;
  </code></pre>
  
  <p>Probably there can be some attribute in B and C with the information that those inherit from A.</p>
  
  <p>This is my base class:</p>
  
  <pre><code>  [Serializable]
    [DataContract(Name = "A")]
    public abstract class A
    {
    }
  </code></pre>
  
  <p>And this is the example of a derived class definition.</p>
  
  <pre><code>  [Serializable]
    [DataContract(Name = "B")]
    public class B : A
    {
    }
  </code></pre>
  
  <p>Since the derived classes are in a different assembly, I can't put any attribute in their base class or the serialized class that would contain a derived class name (for example <code>[XmlElement("B", Type = typeof(ChildB))]</code>) - I don't have the access to derived classes there.  </p>
  
  <p>Is it possible?</p>
  
  <p>While I am currently using <code>DataContractSerializer</code>, I am willing to switch to another XML serializer such as <code>XmlSerializer</code> if necessary.</p>