TryGetValueOrFallback Method
Definition
- Namespace
- Cuemon.Extensions.Collections.Generic
- Assemblies
- Cuemon.Extensions.Collections.Generic.dll
TryGetValueOrFallback<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<IEnumerable<TKey>, TKey>, out TValue)
Gets the value associated with the specified key.
public static bool TryGetValueOrFallback<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<IEnumerable<TKey>, TKey> fallbackKeySelector, out TValue value)
Parameters
dictionaryIDictionary<TKey, TValue>The IDictionary<TKey, TValue> to extend.
keyTKeyThe key of the value to get.
fallbackKeySelectorFunc<IEnumerable<TKey>, TKey>The function delegate that will resolve an alternate key from the specified
key.valueTValueWhen this method returns, contains the value associated with the specified
keyor the alternate key resolved fromfallbackKeySelector, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
- bool
trueif thedictionarycontains an element with the specifiedkeyor the alternate key resolved fromfallbackKeySelector,falseotherwise.
Type Parameters
TKeyThe type of the keys in the
dictionary.TValueThe type of the values in the
dictionary.
Exceptions
- ArgumentNullException
dictionarycannot be null.