IDictionary<TKey,TValue>.GetValueOrDefault Method
Overloads
| GetValueOrDefault(TKey) |
Gets the value for a given key if a matching key exists in the dictionary; returns the default value otherwise. |
| GetValueOrDefault(TKey, TValue) |
Gets the value for a given key if a matching key exists in the dictionary; returns the given default value otherwise. |
Gets the value for a given key if a matching key exists in the dictionary; returns the default value otherwise.
function GetValueOrDefault(const key: TKey): TValue
Parameters
- key
- TKey
The key of the element to get.
Returns
The value associated with the specified key. If the specified key is
not found, Default(TValue) .
Gets the value for a given key if a matching key exists in the dictionary; returns the given default value otherwise.
function GetValueOrDefault(const key: TKey; const defaultValue: TValue): TValue
Parameters
- key
- TKey
The key of the element to get.
- defaultValue
- TValue
The value to return if key is not found.
Returns
The value associated with the specified key. If the specified key is
not found, defaultValue .