Table of Contents

ToEnum Method

Definition

Namespace
Cuemon.Extensions
Assemblies
Cuemon.Extensions.Core.dll
Source
src/Cuemon.Extensions.Core/StringExtensions.cs

ToEnum<TEnum>(string, bool)

Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated TEnum.

public static TEnum ToEnum<TEnum>(this string value, bool ignoreCase = true) where TEnum : struct, IConvertible

Parameters

value string

The string to extend.

ignoreCase bool

true to ignore case; false to regard case.

Returns

TEnum

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

Type Parameters

TEnum

The type of the enumeration to convert.

Exceptions

ArgumentNullException

value is null.

ArgumentException

TEnum does not represents an enumeration.

ArgumentException

value does not represents an enumeration.

See Also