BattleNET.Helpers.EnumValueOf C# (CSharp) Method

EnumValueOf() public static method

public static EnumValueOf ( string value, Type enumType ) : object
value string
enumType System.Type
return object
        public static object EnumValueOf(string value, Type enumType)
        {
            string[] names = Enum.GetNames(enumType);
            foreach (string name in names)
            {
                if (StringValueOf((Enum) Enum.Parse(enumType, name)).Equals(value))
                {
                    return Enum.Parse(enumType, name);
                }
            }

            throw new ArgumentException("The string is not a description or value of the specified enum.");
        }