Dictionary<TKey,TValue>.ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) Dictionary<TKey,TValue>.ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) Dictionary<TKey,TValue>.ICollection<KeyValuePair<TKey,TValue>>.Add(KeyValuePair<TKey,TValue>) Method

定义

添加指定值到带有指定键的 ICollection<T>Adds the specified value to the ICollection<T> with the specified key.

 virtual void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add(System::Collections::Generic::KeyValuePair<TKey, TValue> keyValuePair) = System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<TKey, TValue>>::Add;
void ICollection<KeyValuePair<TKey,TValue>>.Add (System.Collections.Generic.KeyValuePair<TKey,TValue> keyValuePair);
Sub Add (keyValuePair As KeyValuePair(Of TKey, TValue)) Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Add

参数

keyValuePair
KeyValuePair<TKey,TValue> KeyValuePair<TKey,TValue> KeyValuePair<TKey,TValue>

表示要添加到 Dictionary<TKey,TValue> 中的键和值的 KeyValuePair<TKey,TValue> 结构。The KeyValuePair<TKey,TValue> structure representing the key and value to add to the Dictionary<TKey,TValue>.

实现

异常

keyValuePair 的键为 nullThe key of keyValuePair is null.

Dictionary<TKey,TValue> 中已存在具有相同键的元素。An element with the same key already exists in the Dictionary<TKey,TValue>.

适用于