为什么没有一个XML序列化的词典.NET? [英] Why isn't there an XML-serializable dictionary in .NET?

查看:150
本文介绍了为什么没有一个XML序列化的词典.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个XML序列化的字典。其实,我现在有两个需要一种比较不同的程序。我非常惊讶地看到,.NET不具备的。我问的问题在其他地方得到了讽刺的反应。我不明白为什么这是一个愚蠢的问题。

I need an XML-serializable dictionary. Actually, I now have two quite different programs that need one. I was rather surprised to see that .NET doesn't have one. I asked the question elsewhere and got sarcastic responses. I don't understand why it's a stupid question.

能有人开导我,给不同的.NET功能如何依赖都在XML序列化,为什么没有一个XML序列化的字典。希望你也可以解释为什么有些人认为这是一个愚蠢的问题。我想我一定是失去了一些东西根本,我希望你将能够填补国内空白。

Can someone enlighten me, given how dependent various .NET features are on XML serialization, why there isn't an XML-serializable dictionary. Hopefully, you can also explain why some people consider that a daft question. I guess I must be missing something fundamental and I'm hoping you'll be able to fill in the gaps.

推荐答案

有关XML序列化的事情是,它不只是有关创建字节流。这也是关于创建一个XML Schema的字节这个流将验证对。有没有在XML模式没有很好的办法来重新present一本字典。你可以做的最好的是要表明,有一个独特的密钥。

The thing about XML Serialization is that it's not just about creating a stream of bytes. It's also about creating an XML Schema that this stream of bytes would validate against. There's no good way in XML Schema to represent a dictionary. The best you could do is to show that there's a unique key.

您可以随时创建您自己的包装,例如单程将序列词典的。

You can always create your own wrapper, for instance One Way to Serialize Dictionaries.

这篇关于为什么没有一个XML序列化的词典.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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