How do you specify a NonSerialized field with public accessors for XML Serialization?
[NonSerialized]
public String _fooBar;
//Declaring the property here will serialize the _fooBar field
public String FooBar
{
get { return _fooBar; }
set { _fooBar = value; }
}
Properties don't get serialized by BinaryFormatter
, only fields. The [NonSerialized]
attribute has no meaning for XML serialization. Use [XmlIgnore]
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With