IImmutableDictionary<TKey,TValue>.Add(TKey, TValue) IImmutableDictionary<TKey,TValue>.Add(TKey, TValue) IImmutableDictionary<TKey,TValue>.Add(TKey, TValue) IImmutableDictionary<TKey,TValue>.Add(TKey, TValue) Method

定义

将具有指定键和值的元素添加到字典。Adds an element with the specified key and value to the dictionary.

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

参数

key
TKey TKey TKey TKey

要添加的元素的键。The key of the element to add.

value
TValue TValue TValue TValue

要添加的元素的值。The value of the element to add.

返回

一个新的不可变字典,其中包含其他键/值对。A new immutable dictionary that contains the additional key/value pair.

异常

字典中已存在给定的键,但具有不同的值。The given key already exists in the dictionary but has a different value.

注解

如果字典中已存在给定的键/值对,则此方法返回字典的现有实例。If the given key/value pair already exists in the dictionary, this method returns the existing instance of the dictionary.

适用于