Class EnumStringRepresentationExtensions
Provides extension methods for working with the Enum types.
public static class EnumStringRepresentationExtensions
- Inheritance
-
objectEnumStringRepresentationExtensions
Methods
ToEnum<TEnum>(string)
Converts the string representation of the enum value to the actual enum value.
public static TEnum ToEnum<TEnum>(this string stringRepresentation) where TEnum : struct, IConvertible, IComparable, IFormattable
Parameters
stringRepresentationstringString representation of the enum value
Returns
- TEnum
Returns the enum value if it is specified using the EnumStringRepresentationAttribute. Otherwise returns the default enum value.
Type Parameters
TEnumEnum type
ToStringRepresentation(Enum)
Converts the enum value to it's string representation.
public static string ToStringRepresentation(this Enum value)
Parameters
valueEnumEnum value
Returns
- string
Returns the string representation of the enum value if it is specified using the EnumStringRepresentationAttribute. Otherwise returns the enum field name.
ToStringRepresentation<TEnum>(TEnum)
Converts the enum value to it's string representation.
public static string ToStringRepresentation<TEnum>(this TEnum value) where TEnum : struct, IConvertible, IComparable, IFormattable
Parameters
valueTEnumEnum value
Returns
- string
Returns the string representation of the enum value if it is specified using the EnumStringRepresentationAttribute. Otherwise returns the enum field name.
Type Parameters
TEnumEnum type