Difference between SortedList and SortedDictionary in C#

01 May, 2019
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.
Example:
// C# program to illustrate how// to create a sortedlistusing System;using System.Collections;  class GFG {      // Main Method    static public void Main()    {          // Creating a sortedlist        // Using SortedList class        SortedList my_Slist = new SortedList();          // Adding key/value pairs in        // SortedList using Add() method        my_Slist.Add(1.02, "Dog");        my_Slist.Add(1.07, "Cat");        my_Slist.Add(1.04, "Rat");        my_Slist.Add(1.01, "Bird");          foreach(DictionaryEntry pair in my_Slist)        {            Console.WriteLine("{0} and {1}",                      pair.Key, pair.Value);        }        Console.WriteLine();    }}
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.
Example:
// C# program to illustrate how// to create a sorted dictionaryusing System;using System.Collections.Generic;  class GFG {      // Main Method    static public void Main()    {          // Creating sorted dictionary        // Using SortedDictionary class        SortedDictionary<int, string> My_sdict =             new SortedDictionary<int, string>();          // Adding key/value pair in Sorted        // Dictionary Using Add() method        My_sdict.Add(004, "Roscosmos");        My_sdict.Add(003, "ESA");        My_sdict.Add(001, "NASA");        My_sdict.Add(005, "ISRO");        My_sdict.Add(002, "CNSA");        Console.WriteLine("Top 5 space agencies 2018:");          // Accessing the key/value pair of the        // SortedDictionary Using foreach loop        foreach(KeyValuePair<int, string> pair in My_sdict)        {            Console.WriteLine("Rank: {0} and Name: {1}",                                  pair.Key, pair.Value);        }    }}
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:
CSharp SortedDictionary Class
CSharp-Collections-SortedList
C#
Difference Between
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction to .NET Framework
C# | Delegates
C# | Multiple inheritance using interfaces
Differences Between .NET Core and .NET Framework
C# | Data Types
Class method vs Static method in Python
Difference between BFS and DFS
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM