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.

GetValueOrDefault(TKey)

Gets the value for a given key if a matching key exists in the dictionary; returns the default value otherwise.

Delphi
function GetValueOrDefault(const key: TKey): TValue

Parameters

key
TKey

The key of the element to get.

Returns

TValue

The value associated with the specified key. If the specified key is not found, Default(TValue) .

GetValueOrDefault(TKey, TValue)

Gets the value for a given key if a matching key exists in the dictionary; returns the given default value otherwise.

Delphi
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

TValue

The value associated with the specified key. If the specified key is not found, defaultValue .