ConcurrentDictionary<'TKey, 'TValue>.TryUpdate Method ('TKey, 'TValue, 'TValue)

.NET Framework (current version)

The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Compares the existing value for the specified key with a specified value, and if they are equal, updates the key with a third value.

Namespace:   System.Collections.Concurrent
Assembly:  mscorlib (in mscorlib.dll)

member TryUpdate : 
        key:'TKey *
        newValue:'TValue *
        comparisonValue:'TValue -> bool


Type: TKey

The key whose value is compared with comparisonValue and possibly replaced.

Type: TValue

The value that replaces the value of the element that has the specified key if the comparison results in equality.

Type: TValue

The value that is compared to the value of the element that has the specified key.

Return Value

Type: System.Boolean

true if the value with key was equal to comparisonValue and was replaced with newValue; otherwise, false.

Exception Condition

key is null.

The following example shows how to call the TryUpdate method:

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone
Available since 8.1
Return to top