共用方式為


Dictionary<TKey,TValue>.ICollection<KeyValuePair<TKey,TValue>>.Add 方法

定義

將指定的值加入具有指定索引鍵的 ICollection<T>

 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);
abstract member System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add : System.Collections.Generic.KeyValuePair<'Key, 'Value> -> unit
override this.System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<TKey,TValue>>.Add : System.Collections.Generic.KeyValuePair<'Key, 'Value> -> unit
Sub Add (keyValuePair As KeyValuePair(Of TKey, TValue)) Implements ICollection(Of KeyValuePair(Of TKey, TValue)).Add

參數

keyValuePair
KeyValuePair<TKey,TValue>

KeyValuePair<TKey,TValue> 結構,代表要加入 Dictionary<TKey,TValue> 的索引鍵和值。

實作

例外狀況

keyValuePair 的索引鍵是 null

Dictionary<TKey,TValue> 中已存在具有相同索引鍵的元素。

適用於