In C#, SortedList is a collection of key/value pairs which are sorted according to keys. By default, this collection sort the key/value pairs in ascending order. It is of both generic and non-generic type of collection. The generic SortedList is defined in System.Collections.Generic namespace whereas non-generic SortedList is defined under System.Collections namespace.
1.01 and Bird 1.02 and Dog 1.04 and Rat 1.07 and Cat
In C#, SortedDictionary is a generic collection which is used to store the key/value pairs in the sorted form and the sorting is done on the key. SortedDictionary is defined under System.Collection.Generic namespace. It is dynamic in nature means the size of the sorted dictionary is growing according to the need.
Top 5 space agencies 2018: Rank: 1 and Name: NASA Rank: 2 and Name: CNSA Rank: 3 and Name: ESA Rank: 4 and Name: Roscosmos Rank: 5 and Name: ISRO
Below are the some differences between SortedList and SortedDictionary:
|The memory of SortedList is an overhead.||The memory of SortedDictionary is not bottlenecked.|
|In SortedList, the elements are stored in a continuous block in memory.||In SortedDictionary, the elements are stored in separate object that can spread all over the heap.|
|In SoterdList, the memory fragmentation is high.||In SoterdDictionary, the memory fragmentation is low.|
|It require less memory for storage.||It require more memory for storage.|
|In SortedList, less inserts and delete operations are required.||In SortedDictionary, more inserts and delete operations are required.|
|In SortedList, you can access elements using the index.||In SortedDictionary, you can access elements using index or key. Here key access is sufficient there is no need of accessing elements using index.|
|In SortedList, data are already in sorted form.||In SortedDictionary, data are in un-sorted form.|