Reputation: 8594
I have a base class that a number of other classes inherit from. The base class supports XML serialization and has a property that is serializaed.
I would like to keep that same property from serializing in one of the child classes. Is this possible? How do I do it?
Thanks
Tony
Upvotes: 0
Views: 178
Reputation: 1467
You can use the XmlIgnoreAttribute
. See this article.
http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlattributes.xmlignore.aspx
Upvotes: 2
Reputation: 7200
Decorate the property you want to hide with the [XmlIgnore]
attribute:
[Serializable]
[XmlRoot(ElementName = "Customer")]
public class SimplifiedCustomer
{
public string FirstName { get; set; }
public string LastName { get; set; }
[XmlIgnore]
public long CustomerId { get; set; }
}
Upvotes: 1