[英]How to specify a NonSerialized field with public accessors for XML Serialization
How do you specify a NonSerialized field with public accessors for XML Serialization? 如何使用XML序列化的公共访问器指定NonSerialized字段?
[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. 属性不会被BinaryFormatter
序列化,只有字段。 The [NonSerialized]
attribute has no meaning for XML serialization. [NonSerialized]
属性对XML序列化没有意义。 Use [XmlIgnore]
instead. 请改用[XmlIgnore]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.