📄 ex-03-09
字号:
//Example 03-09: The switch statement
using System;
class Values
{
static void Main()
{
const int Democrat = 0;
const int LiberalRepublican = 1;
const int Republican = 2;
const int Libertarian = 3;
const int NewLeft = 4;
const int Progressive = 5;
int myChoice = Libertarian;
switch (myChoice)
{
case Democrat:
Console.WriteLine("You voted Democratic.\n");
break;
case LiberalRepublican: // fall through
//Console.WriteLine(
//"Liberal Republicans vote Republican\n");
case Republican:
Console.WriteLine("You voted Republican.\n");
break;
case NewLeft:
Console.Write("NewLeft is now Progressive");
goto case Progressive;
case Progressive:
Console.WriteLine("You voted Progressive.\n");
break;
case Libertarian:
Console.WriteLine("Libertarians are voting Republican");
goto case Republican;
default:
Console.WriteLine("You did not pick a valid choice.\n");
break;
}
Console.WriteLine("Thank you for voting.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -