Share via


ImmutableInterlocked.TryUpdate<TKey,TValue> 方法

定义

如果指定的键已设置为特定值,则将指定的键设置为指定的值。

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

类型参数

TKey

集合中包含的键的类型。

TValue

集合中包含的值的类型。

参数

location
ImmutableDictionary<TKey,TValue>

要更新的字典。

key
TKey

要更新的键。

newValue
TValue

要设置的新值。

comparisonValue
TValue

返回 key 的当前值,以便更新能够成功。

返回

如果 keycomparisonValue 在字典中存在并且比较已更新为 newValue,则为 true; 否则为 false

适用于