Dev365

每时每分都有新收获

导航

HybridDictionary

Posted on 2004-10-04 21:33  红移  阅读(2080)  评论(3编辑  收藏  举报
ASP.NET中很多地方用了HybridDictionary。我也是第一次知道HybridDictionary。MSDN上是这么说的:
This class is recommended for cases where the number of elements in a dictionary is unknown. It takes advantage of the improved performance of a ListDictionary with small collections, and offers the flexibility of switching to a Hashtable which handles larger collections better than ListDictionary。
写了个程序测试了下,感觉的确如此,在数量小于10个的时候速度比hashtable快,有时快两倍多。我把字符串作为键,如果字串越长,效果越明显。当数量较多的时候速度反而不如hashtable。