ImmutableInterlocked.TryAdd<TKey,TValue> 方法

定義

如果字典中沒有指定的索引鍵,會將指定的索引鍵和值加入字典。

public:
generic <typename TKey, typename TValue>
 static bool TryAdd(System::Collections::Immutable::ImmutableDictionary<TKey, TValue> ^ % location, TKey key, TValue value);
public static bool TryAdd<TKey,TValue> (ref System.Collections.Immutable.ImmutableDictionary<TKey,TValue> location, TKey key, TValue value);
static member TryAdd : ImmutableDictionary * 'Key * 'Value -> bool
Public Shared Function TryAdd(Of TKey, TValue) (ByRef location As ImmutableDictionary(Of TKey, TValue), key As TKey, value As TValue) As Boolean

類型參數

TKey

集合中所包含之索引鍵的類型。

TValue

集合中所包含之值的類型。

參數

location
ImmutableDictionary<TKey,TValue>

要以指定的索引鍵和值更新的字典。

key
TKey

要加入的索引鍵 (如果字典中尚未定義)。

value
TValue

要加入的值。

傳回

如果字典中沒有該索引鍵,則為 true,否則為 false

適用於