411 REFERENCE · Wikibooks
C Sharp Programming/Keywords/switch
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Keywords foreach
__TOC__
The switch statement is a control statement that handles multiple selections and enumerations by passing control to one of the case statements within its body.
This is an example of a switch statement:
int currentAge = 18;
switch (currentAge)
{
case 16:
Console.WriteLine("You can drive!");
break;
case 18:
Console.WriteLine("You're finally an adult!");
break;
default:
Console.WriteLine("Nothing exciting happened this year.");
break;
}
Console Output
You're finally an adult!