GenericExtensionsTryGetEnumValueT Method

Get enum value, based on key, assuming value is a string representation of the enum value. If no data exist for value, or it could not be parsed as an enum value, returns the defaultValue

Definition

Namespace: DHI.Mike1D.Generic
Assembly: DHI.Mike1D.Generic (in DHI.Mike1D.Generic.dll) Version: 24.0.0.0 (11.1.1.1111)
C#
public static T TryGetEnumValue<T>(
	this IDictionary<string, Object> dictionary,
	string key,
	T defaultValue
)
where T : struct, new()

Parameters

dictionary  IDictionaryString, Object
Dictionary to search in
key  String
Identifier/key string of additional data object
defaultValue  T
Default value, if key not found.

Type Parameters

T

[Missing <typeparam name="T"/> documentation for "M:DHI.Mike1D.Generic.GenericExtensions.TryGetEnumValue``1(System.Collections.Generic.IDictionary{System.String,System.Object},System.String,``0)"]

Return Value

T

[Missing <returns> documentation for "M:DHI.Mike1D.Generic.GenericExtensions.TryGetEnumValue``1(System.Collections.Generic.IDictionary{System.String,System.Object},System.String,``0)"]

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IDictionaryString, 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