常见样式 switch(s)
{
case "1":
// ...
case "2":
// ...
}
例子statements_switch2.cs
using System;
class SwitchTest
{
static void Main()
{
int n = 2;
switch(n)
{
case 1:
case 2:
case 3:
Console.WriteLine("It's 1, 2, or 3.");
break;
default:
Console.WriteLine("Not sure what it is.");
break;
}
}
}
|