获取枚举的国际化Key

来源:互联网 发布:php 粘贴 编辑:程序博客网 时间:2024/05/22 15:44
    public class EnumUtils
    {
        public static string GetKey<T>(int value)
        {
            string key = string.Empty;
            bool isDefined = Enum.IsDefined(typeof(T), value);
            if (isDefined)
                key = "Enum." + typeof(T).Name + "." + Enum.Parse(typeof(T), value.ToString()).ToString();
            else
                key = "Enum." + typeof(T).Name + "." + "None";
            return key;
        }
    }
原创粉丝点击