使用XmlSerializer的私人和公共常量性 [英] Using XmlSerializer with private and public const properties

查看:137
本文介绍了使用XmlSerializer的私人和公共常量性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是让XmlSerializer的也序列化类或结构的私人和公共常量性能最简单的方法?右不是所有的它会替我输出的东西是唯一的公共。使其成为私人或加一个const,导致不被序列化的值。

What's the simplest way to get XmlSerializer to also serialize private and "public const" properties of a class or struct? Right not all it will output for me is things that are only public. Making it private or adding const is causing the values to not be serialized.

推荐答案

的XmlSerializer 只着眼于公共字段和属性。如果你需要更多的控制,可以实现的IXmlSerializable 和序列化无论你想。当然,序列化常数没有太大的意义,因为你无法反序列化到一个常数。

XmlSerializer only looks at public fields and properties. If you need more control, you can implement IXmlSerializable and serialize whatever you would like. Of course, serializing a constant doesn't make much sense since you can't deserialize to a constant.

这篇关于使用XmlSerializer的私人和公共常量性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆