Table of Contents

Class EnumExtensions

Namespace
BSGameLib.Core
Assembly
BSGameLib.Core.dll

Converts strings and integers to values of an enum.

public static class EnumExtensions
Inheritance
EnumExtensions
Inherited Members

Methods

ToEnum<TEnum>(int)

Returns the TEnum member with this value.

public static TEnum ToEnum<TEnum>(this int value) where TEnum : struct, Enum

Parameters

value int

Returns

TEnum

Type Parameters

TEnum

Remarks

A combination of flags is not a defined value and is rejected.

Exceptions

ArgumentException

No member of TEnum has this value.

ToEnum<TEnum>(string)

Parses value as TEnum, ignoring case. Numeric text is accepted too.

public static TEnum ToEnum<TEnum>(this string value) where TEnum : struct, Enum

Parameters

value string

Returns

TEnum

Type Parameters

TEnum

Exceptions

ArgumentException

value is not a name or number of TEnum.