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
valueint
Returns
- TEnum
Type Parameters
TEnum
Remarks
A combination of flags is not a defined value and is rejected.
Exceptions
- ArgumentException
No member of
TEnumhas 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
valuestring
Returns
- TEnum
Type Parameters
TEnum
Exceptions
- ArgumentException
valueis not a name or number ofTEnum.