Summary
Gets the element with the specified key or a default value if it is not in the dictionary.
Syntax
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dicionary, TKey key, TValue defaultValue = default(TValue))
Type Parameters
Name |
Description |
TKey |
The type of keys in the dictionary. |
TValue |
The type of values in the dictionary. |
Parameters
Name |
Type |
Description |
dicionary |
IDictionary<TKey, TValue> |
The dictionary to get element from. |
key |
TKey |
The key of the element to get. |
defaultValue |
TValue |
The value to return if element with specified key does not exist in the dicionary. |
Return Value
Type |
Description |
TValue |
The element with the specified key, or the default value. |