gpt4 book ai didi

c# - 如何使用用于 XML 序列化的公共(public)访问器指定非序列化字段

转载 作者:太空狗 更新时间:2023-10-29 20:53:25 44 4
gpt4 key购买 nike

如何为 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/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com