Difference between SortedList and SortedDictionary in C#


Both SortedList and SortedDictionary in C# are the types of data structures used for data storage, now on the basis of characteristics and nature we can distinguish between both of them.

Following are the important differences between SortedList and SortedDictionary.

Sr. No.KeySortedListSortedDictionary
1Memory organizationSortedList requires low memory for storage hence the memory status in its case is overhead.On other hand SortedDictionary requires more memory for storage so memory status in its case is not bottlenecked.
2DesignedSortedList is internally implemented as in sortedList the elements are stored in a continuous block in memory.On other hand in SortedDictionary the elements are stored in separate object that can spread all over the heap.
3FragmentationSortedList requires low memory for storage hence memory fragmentation is high.On other hand due to more memory consumption fragmentation in case of SortedDictionary is low.
4AccessIn SortedList element can be accessed using the index. User can pass the desired known index and could get the value of element stored at that index in the list.On the other hand user can access elements using index or key. In this case key access is sufficient there is no need of accessing elements using index.
5SortingIn SortedList, as name suggest the elements get stored in sorted form.However on other hand in SortedDictionary data get stored in un-sorted form.

Updated on: 09-Jun-2020

505 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements