ImmutableDictionary<TKey,TValue>.SetItem(TKey, TValue) 方法
定义
在不可变字典中设置指定的键和值,可能的设置方法是覆盖该键的现有值。Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key.
public:
System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ SetItem(TKey key, TValue value);
public System.Collections.Immutable.ImmutableDictionary<TKey,TValue> SetItem (TKey key, TValue value);
member this.SetItem : 'Key * 'Value -> System.Collections.Immutable.ImmutableDictionary<'Key, 'Value>
Public Function SetItem (key As TKey, value As TValue) As ImmutableDictionary(Of TKey, TValue)
参数
- key
- TKey
要添加的条目的键。The key of the entry to add.
- value
- TValue
要设置的键值。The key value to set.
返回
一个新的不可变字典,其中包含指定的键/值对。A new immutable dictionary that contains the specified key/value pair.
注解
如果字典中已存在指定的键/值对,则此方法返回字典的现有实例。If the specified key/value pair already exists in the dictionary, this method returns the existing instance of the dictionary. 如果该键已存在,但具有不同的值,则此方法将返回具有覆盖值的字典的新实例。If the key already exists but has a different value, this method returns a new instance of the dictionary with the overwritten value.