为什么不能字典<键,值GT;序列化?或者,可以吗? [英] Why can't a Dictionary<key,value> be serialized? Or can it?

查看:176
本文介绍了为什么不能字典<键,值GT;序列化?或者,可以吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(还没有发现一个问题,问这一点)。

(Havent spotted a question asking this).

为什么不能字典被序列化?

Why cant a Dictionary be serialized?

大多数资源,网站,博客等说,它的不能的序列化。但是看完第3版通过C#CLR,664页给出了字典作为一个对象图其中的的例子可以的序列化。

Most resources, websites, blogs etc say that it cannot be serialized. However reading "CLR via C#" 3rd edition, page 664 gives Dictionary as an example of an object graph which can be serialized.

请注意,大约二进制序列化本章会谈。那么,这是它的可以的使用BinaryFormatter的序列化,但它不能是XML序列化?

Note that this chapter talks about Binary Serialization. So is it that it can be serialized using the BinaryFormatter but it cannot be XML serialized?

或者是有一些区别就在这里,即时通讯一个IDictionary和词典间失踪了?

Or is there some difference here that Im missing between an IDictionary and a Dictionary?

要澄清......在什么情况下可以在词典序列化和在什么情况下能不被序列化。

To clarify... under what circumstances can a Dictionary be serialized and under what circumstances can it not be serialized.

感谢。

推荐答案

您正在寻找的是在这个环节答案:<一href="http://stackoverflow.com/questions/495647/serialize-class-containing-dictionary-member">Serialize包含类字典成员

The answer you're looking for is in this link: Serialize Class containing Dictionary member

您将不得不作出自己的实现,或者用别人的,你可以在这个环节发现:的。NET的XML序列化陷阱?

You're going to have to make your own implementation, or use someone else's as you can find in this link: .NET XML serialization gotchas?

这篇关于为什么不能字典&LT;键,值GT;序列化?或者,可以吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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