DictionaryExtensionsGetValueOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTValue) Method
Namespace: KGySoft.CoreLibrariesAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public static TValue GetValueOrDefault<TKey, TValue>(
this IDictionary<TKey, TValue> dictionary,
TKey key,
Func<TValue> defaultValueFactory
)
<ExtensionAttribute>
Public Shared Function GetValueOrDefault(Of TKey, TValue) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey,
defaultValueFactory As Func(Of TValue)
) As TValue
public:
[ExtensionAttribute]
generic<typename TKey, typename TValue>
static TValue GetValueOrDefault(
IDictionary<TKey, TValue>^ dictionary,
TKey key,
Func<TValue>^ defaultValueFactory
)
[<ExtensionAttribute>]
static member GetValueOrDefault :
dictionary : IDictionary<'TKey, 'TValue> *
key : 'TKey *
defaultValueFactory : Func<'TValue> -> 'TValue
- dictionary IDictionaryTKey, TValue
- The dictionary.
- key TKey
- The key whose value to get.
- defaultValueFactory FuncTValue
- A delegate that can be invoked to return a default value if key was not found..
- TKey
- The type of the stored keys in the dictionary.
- TValue
- Type of the stored values in the dictionary.
TValueThe found value or the result of
defaultValueFactory if
key was not found in the
dictionary.In Visual Basic and C#, you can call this method as an instance method on any object of type
IDictionaryTKey,
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).