SortedDictionary<TKey, TValue>, and SortedList<TKey, TValue>

To keep a dictionary sorted by its key objects, both SortedDictionary<TKey, TValue> and SortedList<TKey, TValue> can be used. They differ in the performance profile of various operations like insertion and deletion, as well as memory consumption. Both use a binary search tree on the inside to make retrieval an O(log n) efficient operation. For more details on the precise differences between both types on the performance front, refer to the MSDN documentation.

The interface of both types is identical to that of the Dictionary<TKey, TValue> type simply because they all implement the corresponding generic dictionary interface. The only difference lies in the ordered characteristic of keys: ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.