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 }

}