SortedList class is a collection of (key, value) pairs which are sorted according to keys. Those pairs can be accessible by key and as well as by index(zero-based indexing). This comes under System.Collections namespace.
Properties of SortedList:
- Internally the object of SortedList maintains two arrays. The first array is used to store the elements of the list i.e. keys and the second one is used to store the associated values.
- A key cannot be null but value can be.
- As SortedList used sorting which makes it slower in comparison to Hashtable.
- The capacity of a SortedList can be dynamically increased through reallocation.
- The keys in the SortedList cannot be duplicated but values can be.
- The SortedList can be sorted according to the keys using the IComparer(Either in ascending or descending order).
Below programs illustrate how to create a SortedList:
- How to create a shallow copy of SortedList Object in C#
- C# | Check if two SortedList objects are equal
- C# | Creating a synchronized (thread-safe) wrapper for a SortedList object
- Difference between SortedList and SortedDictionary in C#
- C# | Check if a SortedList is read-only
- C# | How to add key/value pairs in SortedList
- C# | Check if a SortedList object contains a specific value
- C# | Remove the element with the specified key from a SortedList
- C# | Remove all elements from a SortedList
- C# | Remove from the specified index of a SortedList
- C# | Search in a SortedList object
- C# | Check if a SortedList object is synchronized
- C# | Check if a SortedList object has a fixed size
- C# | SortedList Class
- C# | Capacity of a SortedList
- C# | Get the number of elements contained in SortedList
- C# | Get or set the value associated with specified key in SortedList
- C# | Getting the keys in a SortedList object
- C# | Getting the Values in a SortedList object
- C# | Get an enumerator that iterates through the SortedList
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.