CollectionExtensionsGetOrDefaultTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTKey, TValue) Method
Attempts to get the value for the given key and returns the default value instead if the key does not exist in the IDictionaryTKey, TValue.
Namespace: Gemstone.Collections.CollectionExtensionsAssembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.147 -- Release Build+759c9d29b79c81f10905de8f58b653be932045f0
public static TValue GetOrDefault<TKey, TValue>(
this IDictionary<TKey, TValue> dictionary,
TKey key,
Func<TKey, TValue> defaultValueFactory
)
<ExtensionAttribute>
Public Shared Function GetOrDefault(Of TKey, TValue) (
dictionary As IDictionary(Of TKey, TValue),
key As TKey,
defaultValueFactory As Func(Of TKey, TValue)
) As TValue
public:
[ExtensionAttribute]
generic<typename TKey, typename TValue>
static TValue GetOrDefault(
IDictionary<TKey, TValue>^ dictionary,
TKey key,
Func<TKey, TValue>^ defaultValueFactory
)
JavaScript does not support generic types or methods.
- dictionary IDictionaryTKey, TValue
- The dictionary to check for the given key.
- key TKey
- The key to be checked for the existence of a value.
- defaultValueFactory FuncTKey, TValue
- The function used to generate the default value if no value exists for the given key.
- TKey
- The type of the keys in the dictionary.
- TValue
- The type of the values in the dictionary.
TValueThe value of the key in the dictionary or the default value if no such value exists.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).