开发者

Serializing a private struct - Can it be done?

I have a public class that contains a private struct. The struct contains properties (mostly string) that I want to seria开发者_开发问答lize. When I attempt to serialize the struct and stream it to disk, using XmlSerializer, I get an error saying only public types can be serialized. I don't need, and don't want, this struct to be public. Is there a way I can serialize it and keep it private?


I believe if you implement IXmlSerializable then you should be able to control exactly what and how the data is serialized. If you look at the example in the provided link, they serialize a private string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜