I have two classes : base class name Component and inheritd class named DBComponent
[Serializable]
public class Component
{
private string name = strin
Two options for different scenrios: tell the base-class
[XmlInclude(typeof(DBComponent))]
public class Component
{
private string name = string.Empty;
private string description = string.Empty;
}
Or: tell the collection:
[XmlArray]
[XmlArrayItem("Component", typeof(Component))]
[XmlArrayItem("DBComponent", typeof(DBComponent))]
public List Components {...}
Actually, you can also use [XmlElement(...)] in place of [XmlArrayItem] if you don't want the outer node (Components). Also: you don't need [Serializable].