Click or drag to resize

StringUtilParseEnumT Method

Convert a string to an enum value, returning a default value if the string is null or isn't a valid enum value.

Namespace:  Nova.Utilities
Assembly:  Nova.CodeDOM (in Nova.CodeDOM.dll) Version: 7.44.8391.13415
Syntax
C#
public static T ParseEnum<T>(
	this string thisStr,
	T defaultValue
)
where T : struct, new()

Parameters

thisStr
Type: SystemString
The string to parse.
defaultValue
Type: T
The value to return if parsing fails.

Type Parameters

T
The type of the enum.

Return Value

Type: T
The parsed enum value.

Usage Note

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