EnumExtensions Class
public static class EnumExtensionsNo documentation is available.
Methods
| Name | Description |
|---|---|
| TEnum.Parse(ReadOnlySpan<char>, bool) | Converts the span of chars representation of the name or numeric value of one or more enumerated constants specified by TEnum to an equivalent enumerated object. A parameter specifies whether the operation is case-insensitive. |
| TEnum.Parse(string, bool) | Converts the string representation of the name or numeric value of one or more enumerated constants specified by TEnum to an equivalent enumerated object. A parameter specifies whether the operation is case-insensitive. |
| TEnum.TryParse(ReadOnlySpan<char>, bool, TEnum) | Converts the span of chars representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive. |
| TEnum.TryParse(string?, bool, TEnum) | Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive. |
TEnum.Parse overloads
TEnum.Parse(ReadOnlySpan<char>, bool)
EnumExtensions.csConverts the span of chars representation of the name or numeric value of one or more enumerated constants specified by TEnum to an equivalent enumerated object. A parameter specifies whether the operation is case-insensitive.
extension<TEnum>(TEnum) where TEnum : struct, Enum
{
public static TEnum Parse(ReadOnlySpan<char> value, bool ignoreCase)
}Type parameters
TEnum
Parameters
valueReadOnlySpan<char>- A span containing the name or value to convert.
ignoreCasebooltrueto ignore case;falseto regard case.
Returns
TEnum TEnum An object of type TEnum whose value is represented by value.
Exceptions
ArgumentExceptionTEnumis not anEnumtypeArgumentExceptionvaluedoes not contain enumeration information
TEnum.Parse(string, bool)
EnumExtensions.csConverts the string representation of the name or numeric value of one or more enumerated constants specified by TEnum to an equivalent enumerated object. A parameter specifies whether the operation is case-insensitive.
extension<TEnum>(TEnum) where TEnum : struct, Enum
{
public static TEnum Parse(string value, bool ignoreCase)
}Type parameters
TEnum
Parameters
valuestring- A string containing the name or value to convert.
ignoreCasebooltrueto ignore case;falseto regard case.
Returns
TEnum TEnum An object of type TEnum whose value is represented by value.
Exceptions
ArgumentNullExceptionvalueisnull.ArgumentExceptionTEnumis not anEnumtypeArgumentExceptionvaluedoes not contain enumeration information
TEnum.TryParse overloads
TEnum.TryParse(ReadOnlySpan<char>, bool, TEnum)
EnumExtensions.csConverts the span of chars representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive.
extension<TEnum>(TEnum) where TEnum : struct, Enum
{
public static bool TryParse(ReadOnlySpan<char> value, bool ignoreCase, out TEnum result)
}Type parameters
TEnum
Parameters
valueReadOnlySpan<char>- The span representation of the name or numeric value of one or more enumerated constants.
ignoreCasebooltrueto ignore case;falseto consider case.resultTEnum- When this method returns
true, an object containing an enumeration constant representing the parsed value.
Returns
bool true if the conversion succeeded; false otherwise.
Exceptions
ArgumentExceptionTEnumis not an enumeration type
TEnum.TryParse(string?, bool, TEnum)
EnumExtensions.csConverts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. A parameter specifies whether the operation is case-sensitive.
extension<TEnum>(TEnum) where TEnum : struct, Enum
{
public static bool TryParse(string? value, bool ignoreCase, out TEnum result)
}Type parameters
TEnum
Parameters
valuestring?- The string representation of the name or numeric value of one or more enumerated constants.
ignoreCasebooltrueto ignore case;falseto consider case.resultTEnum- When this method returns
true, an object containing an enumeration constant representing the parsed value.
Returns
bool true if the conversion succeeded; false otherwise.
Exceptions
ArgumentExceptionTEnumis not an enumeration type