枚举类型:
  1.枚举类型只针对字符串,对于索引,无意义
  2.常量的集合,这些常量只能取值,不能赋值
  3.用常量表示所引用的字符串,这样可以省去重复写入长字符串
  练习:
  20人投票,五个候选人,用switch case
//20人投票 switch case 枚举
//投票的时候输入1,2,3,4,5
//利用12345来确定是哪一个候选人得票
//计算得票数
//得票高的胜出
Console.WriteLine("投票选班长!请输入1、2、3、4、5来分别代表张三、李四、王五、赵六、冯七");
int[] shuzu = new int[20];
for (int i = 1; i <= 20; i++)
{
Console.Write("请第" + i + "位同学来进行投票:");
shuzu[i - 1] = int.Parse(Console.ReadLine());
}
Console.WriteLine("投票结束!按下回车开始统计票数!");
Console.ReadLine();
int zhangsan = 0, lisi = 0, wangwu = 0, zhaoliu = 0, fengqi = 0, zuofei = 0;
for (int i = 0; i < 20; i++)
{
switch (shuzu[i])
{
case (int)Houxuanren.one:
zhangsan++;
break;
case (int)Houxuanren.two:
lisi++;
break;
case (int)Houxuanren.three:
wangwu++;
break;
case (int)Houxuanren.four:
zhaoliu++;
break;
case (int)Houxuanren.five:
fengqi++;
break;
default:
zuofei++;
break;
}
}
if (zhangsan > lisi && zhangsan > wangwu && zhangsan > zhaoliu && zhangsan > fengqi)
{
Console.WriteLine("张三胜出!票数为" + zhangsan);
}
else if (lisi > zhangsan && lisi > wangwu && lisi > zhaoliu && lisi > fengqi)
{
Console.WriteLine("李四胜出!票数为" + lisi);
}
else if (wangwu > lisi && wangwu > zhangsan && wangwu > zhaoliu && wangwu > fengqi)
{
Console.WriteLine("王五胜出!票数为" + wangwu);
}
else if (zhaoliu > lisi && zhaoliu > wangwu && zhaoliu > zhangsan && zhaoliu > fengqi)
{
Console.WriteLine("赵六胜出!票数为" + zhaoliu);
}
else if (fengqi > lisi && fengqi > wangwu && fengqi > zhaoliu && fengqi > zhangsan)
{
Console.WriteLine("冯七胜出!票数为" + fengqi);
}
Console.WriteLine("作废的票数为:" + zuofei);
Console.ReadLine();
  即使是下半部,也只是作必须在中断中要做的事情,如保存数据等,其他都交给驱动程序去做。