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.


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


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

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

Return Value

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).


See Also