using System; enum Move
{
walk,
run
}
class Program
{
static float[] speedAry =
{
50.0f,
200.0f }; public static Move move = Move.walk; static void Main(string[] args)
{
//当你要使用枚举,获取对应的数组值得时候. //简洁写法
Console.WriteLine("走的速度: " + speedAry[(int)Move.walk]);
Console.WriteLine("跑的速度: " + speedAry[(int)Move.run]); Console.WriteLine("\n\n"); //复杂写法
switch (move)
{
case Move.walk:
Console.WriteLine("走的速度:" + speedAry[0]);
break;
case Move.run:
Console.WriteLine("跑的速度:" + speedAry[1]);
break;
} Console.ReadLine();
}
}