From Wikibooks, open books for an open world
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!
| C# Keywords | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Special C# Identifiers (Contextual Keywords) | |||||||||||||||
| |||||||||||||||
| Contextual Keywords (Used in Queries) | |||||||||||||||
|