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.

适用于