Jump to content
Wikibooks The Free Textbook Project

C# Programming/Keywords/switch

From Wikibooks, open books for an open world
The latest reviewed version was checked on 11 May 2022. There are template/file changes awaiting review.

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:

intcurrentAge=18;
switch(currentAge)
{
case16:
Console.WriteLine("You can drive!");
break;
case18:
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)

AltStyle によって変換されたページ (->オリジナル) /