SortedList Class

Represents a collection of key/value pairs that are sorted by the keys and are accessible by both key and index.

Namespace: System.Collections

Assembly: System.dll

Inheritance

ObjectSortedList

Implements

Remarks

A SortedList object is a collection of key/value pairs that are sorted by the keys and are accessible by both key and index. The keys in a SortedList object must be unique. The values can be duplicated.

The keys are sorted in ascending order. If a new element is added with a key that already exists, an ArgumentException is thrown.

SortedList maintains the sorted order of its elements. This means that when you add an element, it is inserted in the correct position to maintain the sort order.

SortedList is not synchronized (thread-safe). If you need thread-safe access to the SortedList collection, use the wrapper returned by the SynchronizedCollection method.

Constructors

SortedList()
Initializes a new instance of the SortedList class that is empty, has the default initial capacity, and is sorted by using the default comparer.
SortedList(Int32 capacity)
Initializes a new instance of the SortedList class that is empty, has the specified initial capacity, and is sorted by using the default comparer.
capacity
The initial number of elements that the SortedList can contain.