StringKeyedDictionaryTValueGetValueOrDefaultTActualValue(StringSegment, FuncTActualValue) Method

Tries to get the typed value from the dictionary for the given key. The defaultValueFactory can return an instance of a more specific type than TValue.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public TActualValue GetValueOrDefault<TActualValue>(
	StringSegment key,
	Func<TActualValue> defaultValueFactory
)
where TActualValue : TValue

Parameters

key  StringSegment
The key whose value to get.
defaultValueFactory  FuncTActualValue
A delegate that can be invoked to return a default value if key was not found.

Type Parameters

TActualValue
The type of the value with the corresponding key to get.

Return Value

TActualValue
The found value or the result of defaultValueFactory if key was not found in the dictionary.

Implements

IStringKeyedDictionaryTValueGetValueOrDefaultTActualValue(StringSegment, FuncTActualValue)
IStringKeyedReadOnlyDictionaryTValueGetValueOrDefaultTActualValue(StringSegment, FuncTActualValue)

See Also