当前位置: 移动技术网 > IT编程>开发语言>c# > C# enum

C# enum

2020年01月04日  | 移动技术网IT编程  | 我要评论
static void main(string[] args)
        {
            string[] enumnames = getenumnames(typeof(seasons));
            if(enumnames!=null && enumnames.any())
            {
                foreach(var name in enumnames)
                {
                    console.writeline(name);
                }
            }

            console.writeline(getenumname(typeof(seasons), 1));
            console.readline();
        }

        static string[] getenumnames(type enumtype)
        {
            string[] enumnames = enum.getnames(enumtype);
            return enumnames;
        }

        static string getenumname(type enumtype, int intvalue)
        {
            return enum.getname(enumtype, intvalue);
        } 

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网