IStringKeyedDictionaryTValueGetValueOrDefaultTActualValue(StringSegment, TActualValue) Method

Tries to get the typed value from the dictionary for the given key. The defaultValue parameter can have a more specific type than TValue.

Definition

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

Parameters

key  StringSegment
The key whose value to get.
defaultValue  TActualValue  (Optional)
The default value to return if key was not found or its actual type is not compatible with TActualValue. This parameter is optional.
Default value: if TActualValue is a reference type; otherwise, the bitwise zero value of TActualValue.

Type Parameters

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

Return Value

TActualValue
The found value or defaultValue if key was not found or its value cannot be cast to TActualValue.

See Also