C# 笔记(六)关于switch 语句

在c++中,几种情况共用同一种处理方法时,可以这样写:char a;
switch(a)
{
caes ‘a’,case ‘b’:
{
Dosomething(); 
break;
}
case ‘c’:
……
}

但在c#中必须如下写:

static void Main()
  {
  do
  {
  outMsg(0);
  Console.WriteLine("\n");
  char choice = Console.ReadKey().KeyChar;
  switch (choice)
  {
  case 'i':
  case 'I': //输入信息
  {
  inPut(ref PB);
  outMsg(3);
  writeFile(PB, fileName);
  break;
  }
  case 'v':
  case 'V': //查看记录
  {
  Console.WriteLine("查看记录");
  break;
  }
  case 'e':
  case 'E': //退出系统
  {
  Console.WriteLine("退出系统");
  //Application.Exit();
  break;
  }
  default:
  {
  outMsg(6);
  break;
  }
  }
  } while (true);
  }
原文地址:https://www.cnblogs.com/chutianyao/p/1288313.html