GetValueOrDefault Method
Definition
- Namespace
- Cuemon.Collections.Generic
- Assemblies
- Cuemon.Core.dll
GetValueOrDefault<TKey, TValue>(IDecorator<IDictionary<TKey, TValue>>, TKey)
Gets the value associated with the specified key or default when the key does not exists in the enclosed IDictionary<TKey, TValue> of the decorator.
public static TValue GetValueOrDefault<TKey, TValue>(this IDecorator<IDictionary<TKey, TValue>> decorator, TKey key)
Parameters
decoratorIDecorator<IDictionary<TKey, TValue>>The IDecorator<T> to extend.
keyTKeyThe key of the value to get.
Returns
- TValue
Either the value associated with the specified
keyordefault(when the key does not exists.TValue)
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.
Exceptions
- ArgumentNullException
decoratorcannot be null -or-keycannot be null.
GetValueOrDefault<TKey, TValue>(IDecorator<IDictionary<TKey, TValue>>, TKey, Func<TValue>)
Gets the value associated with the specified key or a default value through defaultProvider when the key does not exists in the enclosed IDictionary<TKey, TValue> of the decorator.
public static TValue GetValueOrDefault<TKey, TValue>(this IDecorator<IDictionary<TKey, TValue>> decorator, TKey key, Func<TValue> defaultProvider)
Parameters
decoratorIDecorator<IDictionary<TKey, TValue>>The IDecorator<T> to extend.
keyTKeyThe key of the value to get.
defaultProviderFunc<TValue>The function delegate that will provide a default value when the
keydoes not exists in the enclosed IDictionary<TKey, TValue> of thedecorator.
Returns
- TValue
Either the value associated with the specified
keyor a default value throughdefaultProviderwhen the key does not exists.
Type Parameters
TKeyThe type of the keys in the dictionary.
TValueThe type of the values in the dictionary.
Exceptions
- ArgumentNullException
decoratorcannot be null -or-keycannot be null -or-defaultProvidercannot be null.