EnumExtensions Class

public static class EnumExtensions

No documentation is available.

Methods

NameDescription
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.cs

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.

extension<TEnum>(TEnum) where TEnum : struct, Enum
{
    public static TEnum Parse(ReadOnlySpan<char> value, bool ignoreCase)
}
Type parameters
TEnum
Parameters
value ReadOnlySpan<char>
A span containing the name or value to convert.
ignoreCase bool
true to ignore case; false to regard case.
Returns

TEnum TEnum An object of type TEnum whose value is represented by value.

Exceptions
ArgumentException
TEnum is not an Enum type
ArgumentException
value does not contain enumeration information

TEnum.Parse(string, bool)

EnumExtensions.cs

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.

extension<TEnum>(TEnum) where TEnum : struct, Enum
{
    public static TEnum Parse(string value, bool ignoreCase)
}
Type parameters
TEnum
Parameters
value string
A string containing the name or value to convert.
ignoreCase bool
true to ignore case; false to regard case.
Returns

TEnum TEnum An object of type TEnum whose value is represented by value.

Exceptions
ArgumentNullException
value is null.
ArgumentException
TEnum is not an Enum type
ArgumentException
value does not contain enumeration information

TEnum.TryParse overloads

TEnum.TryParse(ReadOnlySpan<char>, bool, TEnum)

EnumExtensions.cs

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.

extension<TEnum>(TEnum) where TEnum : struct, Enum
{
    public static bool TryParse(ReadOnlySpan<char> value, bool ignoreCase, out TEnum result)
}
Type parameters
TEnum
Parameters
value ReadOnlySpan<char>
The span representation of the name or numeric value of one or more enumerated constants.
ignoreCase bool
true to ignore case; false to consider case.
result TEnum
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
ArgumentException
TEnum is not an enumeration type

TEnum.TryParse(string?, bool, TEnum)

EnumExtensions.cs

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.

extension<TEnum>(TEnum) where TEnum : struct, Enum
{
    public static bool TryParse(string? value, bool ignoreCase, out TEnum result)
}
Type parameters
TEnum
Parameters
value string?
The string representation of the name or numeric value of one or more enumerated constants.
ignoreCase bool
true to ignore case; false to consider case.
result TEnum
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
ArgumentException
TEnum is not an enumeration type