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); }
来源:https://www.cnblogs.com/Fred1987/archive/2020/01/03/12144958.html