public class EnumHelper
{
    /// <summary>
    /// 根据枚举值获取枚举名称
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="value"></param>
    /// <returns></returns>
    public static string GetEnumName<T>(int value)
    {
        try
        {
            var res = Enum.GetName(typeof(T), value);
            if (res != null)
                return res;
            else
                return "未知类型";
        }
        catch
        {
            return "未知类型";
        }
    }


    /// <summary>
    /// 获取枚举的名称及对应值
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns></returns>
    public static Dictionary<string, int> GetEnumNameValue<T>(params Enum[] enums)
    {        
        Dictionary<string, int> dic = new Dictionary<string, int>();
        foreach (int i in Enum.GetValues(typeof(T)))
        {
            var res = Enum.GetName(typeof(T), i);
            dic.Add(res, i);
        }
        return dic;
    }
}