EnumHelpers.ParseEnum method
Version 1.1.28
.NET Framework 4.8
| Namespace | Skybrud.Essentials.Enums |
|---|---|
| Assembly | Skybrud.Essentials.dll |
ParseEnum<T>(string)
Static
Parses the specified str into the enum of type T.
public static T ParseEnum<T>(string str)
Type Parameters
T
The type of the enum.
Parameters
str
String
The string to be parsed.
Returns
T
An enum of type T from the specified str.
Exceptions
If str is null (or white space).
If T is not an enum class.
If str doesn't match any of the values of T.
ParseEnum<T>(string, T)
Static
Parses the specified str into the enum of type T.
public static T ParseEnum<T>(string str, T fallback)
Type Parameters
T
The type of the enum.
Parameters
str
String
The string to be parsed.
fallback
T
The fallback if the enum could not be parsed.
Returns
T
An enum of type T from the specified str.
Exceptions
If T is not an enum class.