ImmutableDictionary<TKey,TValue>.Add(TKey, TValue) 方法

定義

將具有指定索引鍵和值的項目加入不可變字典。

public:
 System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ Add(TKey key, TValue value);
public System.Collections.Immutable.ImmutableDictionary<TKey,TValue> Add (TKey key, TValue value);
member this.Add : 'Key * 'Value -> System.Collections.Immutable.ImmutableDictionary<'Key, 'Value>
Public Function Add (key As TKey, value As TValue) As ImmutableDictionary(Of TKey, TValue)

參數

key
TKey

要加入的項目的索引鍵。

value
TValue

要加入的項目的值。

傳回

新的不可變字典,其中包含其他索引鍵/值組。

例外狀況

字典中已經存在指定的索引鍵,但有不同的值。

備註

如果字典中已有指定的索引鍵/值組,則會傳回字典的現有實例。

適用於