如何为 XML 序列化指定带有公共(public)访问器的非序列化字段?
[NonSerialized]
public String _fooBar;
//Declaring the property here will serialize the _fooBar field
public String FooBar
{
get { return _fooBar; }
set { _fooBar = value; }
}
最佳答案
BinaryFormatter
不会序列化属性,只有字段。 [NonSerialized]
属性对 XML 序列化没有意义。请改用 [XmlIgnore]
。
关于c# - 如何使用用于 XML 序列化的公共(public)访问器指定非序列化字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5560532/