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.
精彩评论