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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.