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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.