DictionaryExtensionsGetValueOrDefaultTActualValue(IEnumerableKeyValuePairString, Object, String, TActualValue) Method

Tries to get the typed value from a string-object dictionary for the given key.
See the Examples section of the GetValueOrDefaultTActualValue(IDictionaryString, Object, String, TActualValue) method for some examples.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
public static TActualValue GetValueOrDefault<TActualValue>(
	this IEnumerable<KeyValuePair<string, Object>> dictionary,
	string key,
	TActualValue defaultValue = null
)

Parameters

dictionary  IEnumerableKeyValuePairString, Object
The dictionary.
key  String
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.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerableKeyValuePairString, Object. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

See Also