Is there any real practical difference between a SortedList<TKey,TValue> and a SortedDictionary<TKey,TValue>? Are there any circumstances where you would specifically use one and not the other?
Is there any real practical difference between a SortedList<TKey,TValue> and a SortedDictionary<TKey,TValue> ? Are
Share
Yes – their performance characteristics differ significantly. It would probably be better to call them
SortedListandSortedTreeas that reflects the implementation more closely.Look at the MSDN docs for each of them (
SortedList,SortedDictionary) for details of the performance for different operations in different situtations. Here’s a nice summary (from theSortedDictionarydocs):(
SortedListactually maintains a sorted array, rather than using a tree. It still uses binary search to find elements.)