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

posted @ 2018-07-22 11:03  chenjingchun  阅读(9553)  评论(0编辑  收藏  举报