現在我建一个Enum如下
    Enum MyData
        Apple = 0
        Orange = 1
        Car = 2
        Bus = 3
    End Enum
現在我想當用戶輸入0的時候,可以從MyData裡找到Apple,然後顯示Apple給用戶.

解决方案 »

  1.   

    这是什么语言的,枚举直接就MyData.Apple ??
    要不然放入数组里用索引判断!!
    等高手,
      

  2.   

            public enum MyData : int
            {
                Apple = 0,
                Orange = 1,
                Car = 2,
                Bus = 3
            }        static void Main(string[] args)
            {
                for (int i = 0; i < 4; i++)
                {
                    Console.WriteLine(GetResultString(i));
                }
                Console.ReadKey();
            }        public static String GetResultString(int value)
            {
                MyData md = (MyData)value;
                return md.ToString();
            }