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

定義

設定不可變字典中指定的索引鍵和值,可能會覆寫索引鍵的現有值。

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

要加入的項目索引鍵。

value
TValue

要設定的索引鍵值。

傳回

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

備註

如果指定的索引鍵/值組已存在於字典中,這個方法會傳回字典的現有實例。 如果索引鍵已經存在,但具有不同的值,這個方法會傳回含有覆寫值之字典的新實例。

適用於