-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_DictionaryExtensions_AddOrUpdate__2_3
DictionaryExtensions.AddOrUpdate(TKey, TValue) Method (IDictionary(TKey, TValue), TKey, TValue, Func(TKey, TValue, TValue))
Adds a key/value pair to the IDictionary(TKey, TValue) if the key does not already exist, or updates a key/value pair IDictionary(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 IDictionary<TKey, TValue> dictionary,
TKey key,
TValue addValue,
Func<TKey, TValue, TValue> updateValueFactory
)
VB
<ExtensionAttribute>
Public Shared Function AddOrUpdate(Of TKey, TValue) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey,
addValue As TValue,
updateValueFactory As Func(Of TKey, TValue, TValue)
) As TValue
F#
[<ExtensionAttribute>]
static member AddOrUpdate :
dictionary : IDictionary<'TKey, 'TValue> *
key : 'TKey *
addValue : 'TValue *
updateValueFactory : Func<'TKey, 'TValue, 'TValue> -> 'TValue
- dictionary
- Type: System.Collections.Generic.IDictionary(TKey, TValue)
The dictionary. - key
- Type: TKey
The key to be added or whose value should be updated - addValue
- Type: TValue
The value to be added for an absent key - updateValueFactory
- Type: System.Func(TKey, TValue, TValue)
The function used to generate a new value for an existing key based on the key's existing value
- TKey
- [Missing documentation for "M:CodeJam.Collections.DictionaryExtensions.AddOrUpdate
2(System.Collections.Generic.IDictionary{
0,1},
0,1,System.Func{
0,1,
1})"] - TValue
- [Missing documentation for "M:CodeJam.Collections.DictionaryExtensions.AddOrUpdate
2(System.Collections.Generic.IDictionary{
0,1},
0,1,System.Func{
0,1,
1})"]
Type: TValue
The new value for the key. This will be either be addValue (if the key was absent) or the result of updateValueFactory (if the key was present).
In Visual Basic and C#, you can call this method as an instance method on any object of type IDictionary(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