开发者

XML Serialization of nested classes having Dictionary

开发者 https://www.devze.com 2022-12-25 04:06 出处:网络
I am trying to XML-serialize a nested class. Both classes have dictionaries which I am serializing using this li开发者_开发问答nk.

I am trying to XML-serialize a nested class. Both classes have dictionaries which I am serializing using this li开发者_开发问答nk.

Serialization works fine but the nested class doesn't get de-serialized. Can you please let me know how to do it?


Implement IXmlSerializable on the class that you need to serialize. It's a bit of extra work, but it provides a much nicer way to control XML output for your classes.

If you do this, serializing a dictionary should not be a issue.


XML Serialization does not serialize nested classes. It only serializes member fields/properties of a class. If you want to serialize a nested class, you should have a field of the nested class type in the parent class.

0

精彩评论

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

关注公众号