NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

SortedList Constructor (IDictionary, IComparer)

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
);

Parameters

d
The IDictionary to copy into a new SortedList.
comparer
The IComparer implementation to use when comparing keys.

-or-

a null reference (in Visual Basic Nothing) to use the IComparable implementation of each key.

Exceptions

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.

Remarks

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.

See Also

SortedList Class | SortedList Members | System.Collections Namespace | SortedList Constructor Overload List | IDictionary | IComparer | IComparable | Dictionary | Hashtable | Capacity