Copies the entries from a dictionary to a new SortedList, sorted according to the specified IComparer interface.
[Visual Basic] Overloads Public Sub New( _ ByVal d As IDictionary, _ ByVal comparer As IComparer _ ) [C#] public SortedList( IDictionary d, IComparer comparer ); [C++] public: SortedList( IDictionary* d, IComparer* comparer ); [JScript] public function SortedList( d : IDictionary, comparer : IComparer );
-or-
a null reference (in Visual Basic Nothing) to use the IComparable implementation of each key.
Exception Type | Condition |
---|---|
ArgumentNullException | d is a null reference (Nothing). |
InvalidCastException | comparer is a null reference (Nothing), and one or more elements in d do not implement the IComparable interface. |
When adding elements to the list and the number of elements exceeds the capacity, the capacity is doubled.
The elements are sorted according to the specified IComparer implementation. If comparer is a null reference (Nothing), the IComparable implementation of each key is used.
A Hashtable is an example of a Dictionary that can be passed to this constructor. The new SortedList will contain a copy of the keys and values stored in the Hashtable.
SortedList Class | SortedList Members | System.Collections Namespace | SortedList Constructor Overload List | IDictionary | IComparer | IComparable | Dictionary | Hashtable | Capacity