C#遍历枚举
class Program { static void Main(string[] args) { foreach (int v in Enum.GetValues(typeof(OrderType))) { string strName = Enum.GetName(typeof(OrderType), v); Console.WriteLine("key:{0}value:{1}", strName, v); } Console.ReadKey(); } } public enum OrderType { 未付款 = 1, 未发货 = 2, 未评价 = 3 }
画重点=>foreach中用int