語言

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

適用於