Class EnumHelper
Provides utility methods for working with enumerations.
Inherited Members
Namespace: mk.helpers
Assembly: mk.helpers.dll
Syntax
public static class EnumHelper
Methods
Parse<T>(string)
Parses a string representation of an enumeration value to its corresponding enumeration value.
Declaration
public static T Parse<T>(string text) where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The string representation of the enumeration value to parse. |
Returns
| Type | Description |
|---|---|
| T | The parsed enumeration value. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the enumeration. |
Remarks
This method attempts to parse the input text into the specified enumeration type. It supports variations in formatting such as underscores and spaces, and attempts to match the case-insensitive enum member names.
TryParse<T>(string, out T)
Tries to parse a string representation of an enumeration value to its corresponding enumeration value.
Declaration
public static bool TryParse<T>(string text, out T result) where T : struct, IConvertible
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The string representation of the enumeration value to parse. |
| T | result | When this method returns, contains the parsed enumeration value if the parsing was successful. |
Returns
| Type | Description |
|---|---|
| bool |
|
Type Parameters
| Name | Description |
|---|---|
| T | The type of the enumeration. |
Remarks
This method attempts to parse the input text into the specified enumeration type. It supports variations in formatting such as underscores and spaces, and attempts to match the case-insensitive enum member names.