Non Serialized Properties
A fellow has asked me the easiest way of NOT serializing a property when using XML serialization...
You can not use the NonSerializable attribute for properties because this attribute is only valid for public fields, but there is another attribute in the System.Xml.Serialization namespace which is XmlIgnore.
This attribute will tell the xml serializer to ignore the property when serializing / deserializing. Such as:
[XmlIgnore()]
public string PropertyName {
get { //code here }
set { //code here }
}
Comments
Anonymous
December 29, 2007
PingBack from http://msdn.blogsforu.com/msdn/?p=2809Anonymous
May 27, 2010
Thanks for the [Xmlignore()] tip - I'd been trying all kinds of things to get the property ignored, and this finally worked for me!