-
Notifications
You must be signed in to change notification settings - Fork 36
M_CodeJam_Collections_DictionaryExtensions_AddOrUpdate__2
Andrew Koryavchenko edited this page Jun 17, 2018
·
10 revisions
DictionaryExtensions.AddOrUpdate(TKey, TValue) Method (ConcurrentDictionary(TKey, TValue), TKey, Func(TKey, TValue))
Adds a key/value pair to the ConcurrentDictionary(TKey, TValue) if the key does not already exist, or updates a key/value pair ConcurrentDictionary(TKey, TValue) by using the specified function if the key already exists.
Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static TValue AddOrUpdate<TKey, TValue>(
this ConcurrentDictionary<TKey, TValue> dictionary,
TKey key,
Func<TKey, TValue> valueFactory
)
VB
<ExtensionAttribute>
Public Shared Function AddOrUpdate(Of TKey, TValue) (
dictionary As ConcurrentDictionary(Of TKey, TValue),
key As TKey,
valueFactory As Func(Of TKey, TValue)
) As TValue
F#
[<ExtensionAttribute>]
static member AddOrUpdate :
dictionary : ConcurrentDictionary<'TKey, 'TValue> *
key : 'TKey *
valueFactory : Func<'TKey, 'TValue> -> 'TValue
- dictionary
- Type: System.Collections.Concurrent.ConcurrentDictionary(TKey, TValue)
The dictionary. - key
- Type: TKey
The key to be added or whose value should be updated - valueFactory
- Type: System.Func(TKey, TValue)
The function used to generate a value.
- TKey
- [Missing documentation for "M:CodeJam.Collections.DictionaryExtensions.AddOrUpdate
2(System.Collections.Concurrent.ConcurrentDictionary{
0,1},
0,System.Func{0,
1})"] - TValue
- [Missing documentation for "M:CodeJam.Collections.DictionaryExtensions.AddOrUpdate
2(System.Collections.Concurrent.ConcurrentDictionary{
0,1},
0,System.Func{0,
1})"]
Type: TValue
The new value for the key.
In Visual Basic and C#, you can call this method as an instance method on any object of type ConcurrentDictionary(TKey, TValue). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
DictionaryExtensions Class
AddOrUpdate Overload
CodeJam.Collections Namespace