Adds an element with the specified key and value into the SortedList.
[Visual Basic] Overridable Public Sub Add( _ ByVal key As Object, _ ByVal value As Object _ ) [C#] public virtual void Add( object key, object value ); [C++] public: virtual void Add( Object* key, Object* value ); [JScript] public function Add( key : Object, value : Object );
None.
Exception Type | Condition |
---|---|
ArgumentNullException | key is a null reference (in Visual Basic Nothing). |
ArgumentException | An element with the specified key already exists in the SortedList.
-or- The SortedList is set to use the IComparable interface, and key does not implement the IComparable interface. |
This method can be overridden by a derived class.
When adding elements to the list and the number of elements exceeds the capacity, the capacity is doubled.The insertion point is determined based on the comparer selected, either explicitly or by default, when the SortedList was instantiated.
a null reference (Nothing) is not allowed as a key, but is allowed as a value.
SortedList Class | SortedList Members | System.Collections Namespace | Item | IComparer | IComparable | Capacity