C#字典性能 [英] C# Dictionary Performance

查看:1187
本文介绍了C#字典性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用字典来存储数据,并且将其高速缓存。我想,以避免服务器内存的问题,并通过限制词典&LT的大小都有不错的表现;>,无论是在规模还是参赛人数结果
什么是这样做的最好的方法?有没有我应该考虑比字典?

I am using a Dictionary to store data, and will be caching it. I would like to avoid server memory issues, and have good performance by limiting the size of the Dictionary<>, either in size or number of entries.
What is the best method of doing this? Is there another class I should be considering other than a Dictionary?

推荐答案

有可供选择的几个其他类,如

There are several other classes you can select from like

您可以通过查看系统查看选项.Collections.Generic 命名空间。

you can review the options by looking at System.Collections.Generic Namespace.

他们是一个很好的职位,describibg优点和在MSDN

Their is a very good post, describibg pros and cons for all most of the collection classes at MSDN

如果你没有被什么这些类提供满意的,你可以去为自己的集合类或设计自定义词典你的自我。

If you are not satisfied by what these classes are provide, you can go for your own collection class or design a custom Dictionary your self.

您将需要继承您的自定义词典弗朗IDictionary的接口和其它类/接口或者可以写信一切从零开始。

you will need to inherit your custom dictionary fron IDictionary Interface and other classes / interfaces or may write all from scratch.

下面是 Dictionary类 在MSDN

Here is the signature for Dictionary class at MSDN

[SerializableAttribute]
[ComVisibleAttribute(false)]
public class Dictionary<TKey, TValue> : IDictionary<TKey, TValue>, 
    ICollection<KeyValuePair<TKey, TValue>>,
    IEnumerable<KeyValuePair<TKey, TValue>>, 
    IDictionary, ICollection, IEnumerable,
    ISerializable, IDeserializationCallback

这篇关于C#字典性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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