Xml serialization
Hi,
I am trying to hind a public property of a base class from the serialization of the derived class. But it does not work. Where is my mistake?
Code:
[XmlRoot("Components")
public class Component
{
private List<Part> _parts = new List<Part>();
[XmlElement("Parts")]
public virtual List<Part> Parts
{
get { return _parts; }
set { _parts = value; }
}
}
[XmlRoot("Other_Components")]
public class ComponentA : Component
{
[XmlIgnore]
public override List<Part> Parts
{
get { return base.Parts; }
set { base.Parts = value; }
}
}
If I serialize ComponentA I do not want serialize Parts. But this code fails. Any hints?
Useful or not? Rate my posting. Thanks.