StringDictionary vs Dictionary<string, string> [英] StringDictionary vs Dictionary&lt;string, string&gt;

查看:29
本文介绍了StringDictionary vs Dictionary<string, string>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道 System.Collections.Specialized.StringDictionary 对象和 System.Collections.Generic.Dictionary 之间的实际区别是什么?

Does anyone have any idea what the practical differences are between the System.Collections.Specialized.StringDictionary object and System.Collections.Generic.Dictionary?

我过去曾使用过它们,并没有想过哪一个会表现更好、与 Linq 配合得更好,或者提供任何其他好处.

I've used them both in the past without much thought as to which would perform better, work better with Linq, or provide any other benefits.

关于为什么我应该使用一个而不是另一个的任何想法或建议?

Any thoughts or suggestions as to why I should use one over the other?

推荐答案

Dictionary 是一种更现代的方法.它实现了 IEnumerable 并且它更适合于 LINQy 的东西.

Dictionary<string, string> is a more modern approach. It implements IEnumerable<T> and it's more suited for LINQy stuff.

StringDictionary 是老派的方式.它在泛型时代之前就存在了.我只会在与遗留代码交互时使用它.

StringDictionary is the old school way. It was there before generics days. I would use it only when interfacing with legacy code.

这篇关于StringDictionary vs Dictionary<string, string>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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