-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_DictionaryExtensions_GetValueOrDefault__2_7
Andrew Koryavchenko edited this page Jun 17, 2018
·
5 revisions
DictionaryExtensions.GetValueOrDefault(TKey, TValue) Method (IDictionary(TKey, TValue), TKey, Func(TKey, TValue))
Returns value associated with key, or value returned by defaultValueFactory if key does not exists in dictionary
Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static TValue GetValueOrDefault<TKey, TValue>(
this IDictionary<TKey, TValue> dictionary,
TKey key,
Func<TKey, TValue> defaultValueFactory
)
VB
<ExtensionAttribute>
Public Shared Function GetValueOrDefault(Of TKey, TValue) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey,
defaultValueFactory As Func(Of TKey, TValue)
) As TValue
F#
[<ExtensionAttribute>]
static member GetValueOrDefault :
dictionary : IDictionary<'TKey, 'TValue> *
key : 'TKey *
defaultValueFactory : Func<'TKey, 'TValue> -> 'TValue
- dictionary
- Type: System.Collections.Generic.IDictionary(TKey, TValue)
The dictionary. - key
- Type: TKey
The key. - defaultValueFactory
- Type: System.Func(TKey, TValue)
Function to return default value.
- TKey
- The type of the key.
- TValue
- The type of the value.
Type: TValue
Value, associated with the key, or value returned by defaultValueFactory if key does not exists in dictionary
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
GetValueOrDefault Overload
CodeJam.Collections Namespace