-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_DictionaryExtensions_AddOrUpdate__2_1
Andrew Koryavchenko edited this page Jun 17, 2018
·
10 revisions
DictionaryExtensions.AddOrUpdate(TKey, TValue) Method (IDictionary(TKey, TValue), TKey, Func(TKey, 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,
Func<TKey, TValue> valueFactory
)
VB
<ExtensionAttribute>
Public Shared Function AddOrUpdate(Of TKey, TValue) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey,
valueFactory As Func(Of TKey, TValue)
) As TValue
F#
[<ExtensionAttribute>]
static member AddOrUpdate :
dictionary : IDictionary<'TKey, 'TValue> *
key : 'TKey *
valueFactory : Func<'TKey, '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 - 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.Generic.IDictionary{
0,1},
0,System.Func{0,
1})"] - TValue
- [Missing documentation for "M:CodeJam.Collections.DictionaryExtensions.AddOrUpdate
2(System.Collections.Generic.IDictionary{
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 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