Dictionary<'TKey, 'TValue>.ICollection<KeyValuePair<'TKey, 'TValue>>.Add Method (KeyValuePair<'TKey, 'TValue>)
Adds the specified value to the ICollection<'T> with the specified key.
Assembly: mscorlib (in mscorlib.dll)
private abstract Add : keyValuePair:KeyValuePair<'TKey, 'TValue> -> unit private override Add : keyValuePair:KeyValuePair<'TKey, 'TValue> -> unit
Parameters
- keyValuePair
-
Type:
System.Collections.Generic.KeyValuePair<'TKey, 'TValue>
The KeyValuePair<'TKey, 'TValue> structure representing the key and value to add to the Dictionary<'TKey, 'TValue>.
Implements
ICollection<'T>.Add('T)| Exception | Condition |
|---|---|
| ArgumentNullException | The key of keyValuePair is null. |
| ArgumentException | An element with the same key already exists in the Dictionary<'TKey, 'TValue>. |
The following example shows how to use the ICollection<KeyValuePair<'TKey, 'TValue>>.Add, ICollection<KeyValuePair<'TKey, 'TValue>>.Contains, ICollection<KeyValuePair<'TKey, 'TValue>>.CopyTo, and ICollection<KeyValuePair<'TKey, 'TValue>>.Remove methods of the ICollection<'T> generic interface to manipulate a Dictionary<'TKey, 'TValue> object.
Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: