将 XML 可序列化公共字段重构为自动属性是否会破坏旧实例的反序列化?
我有一个类,其中有许多标有 XML 可序列化属性的公共字段:
[XmlAttribute]
public string ExampleField = string.Empty;
我打算将这些字段(并且仅这些字段)重构为自动属性:
[XmlAttribute]
public string ExampleField { get; set; }
反序列化使用之前创建的实例是否会出现任何问题课程的版本?
I have a class which has a number of public fields that are marked with XML serializable attributes:
[XmlAttribute]
public string ExampleField = string.Empty;
I intend to refactor these fields (and only these fields) as auto-properties:
[XmlAttribute]
public string ExampleField { get; set; }
Will there be any issue with deserializing instances that were created using the previous version of the class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它似乎工作得很好...
(
XmlSerializer
是我的 .Net Xml 序列化类的包装器。)输出:
It appears to work just fine...
(
XmlSerializer
is my wrapper to the .Net Xml Serialization classes.)Output: