SortedDictionary.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add Method
Note: This method is new in the .NET Framework version 2.0.
Adds an item to the ICollection.
Namespace: System.Collections.Generic
Assembly: System (in system.dll)
Syntax
'Declaration
Private Sub System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add ( _
keyValuePair As KeyValuePair(Of TKey, TValue) _
) Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Add
'Usage
Dim instance As SortedDictionary(Of TKey, TValue)
Dim keyValuePair As KeyValuePair(Of TKey, TValue)
CType(instance, ICollection(Of KeyValuePair(Of TKey, TValue))).Add(keyValuePair)
void ICollection<KeyValuePair<TKey,TValue>>.Add (
KeyValuePair<TKey,TValue> keyValuePair
)
private:
virtual void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add (
KeyValuePair<TKey, TValue> keyValuePair
) sealed = ICollection<KeyValuePair<TKey, TValue>>::Add
J# supports the use of explicit interface implementations, but not the declaration of new ones.
JScript supports the use of explicit interface implementations, but not the declarations of new ones.
Parameters
- keyValuePair
The KeyValuePair structure to add to the ICollection.
Exceptions
Exception type | Condition |
---|---|
keyValuePair is a null reference (Nothing in Visual Basic). |
|
An element with the same key already exists in the SortedDictionary. |
Remarks
A key cannot be a null reference (Nothing in Visual Basic), but a value can be, if the value type TValue is a reference type.
This method is an O(log n) operation, where n is Count.
Platforms
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Version Information
.NET Framework
Supported in: 2.0
See Also
Reference
SortedDictionary Generic Class
SortedDictionary Members
System.Collections.Generic Namespace
ICollection.IsReadOnly Property