语言

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

要添加的元素的值。

返回

包含附加键/值对的新不可变字典。

例外

给定键已存在于字典中,但具有不同的值。

注解

如果字典中已存在给定键/值对,则会返回字典的现有实例。

适用于