C# enum
程序员文章站
2022-03-25 17:57:21
static void Main(string[] args) { string[] enumNames = GetEnumNames(typeof(Seasons)); if(enumNames!=null && enumNames.Any()) { foreach(var name in enu... ......
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); }