SortedList internally uses the array as the data structure to store, and then simply sorts the array as needed to keep the elements in order. Since it uses an array, elements can be accessed using a numerical index, as with any array.
SortedDictionary internally uses a red black binary data tree to keep items in order. The concept is completely different. There is no array and there is no analogue for extracting elements using a numerical index. Your only option is to use the key part of the key-value pair that has been added to the dictionary.
That said. Your code looks right to me. This is the only way to retrieve items from a dictionary (other than using the Values ββcollection, but it will also not give you a numerical indexing ability).
source share