How to specify a non-serialized field with public XML serialization accessories

How do you define a NonSerialized field with public XML serialization accessories?

[NonSerialized] public String _fooBar; //Declaring the property here will serialize the _fooBar field public String FooBar { get { return _fooBar; } set { _fooBar = value; } } 
+6
c # serialization xml-serialization
source share
1 answer

Properties are not serialized by BinaryFormatter , but only fields. The [NonSerialized] attribute does not make sense for XML serialization. Use [XmlIgnore] .

+16
source share

All Articles