C# Programming/Keywords/switch
Appearance
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.
C# Programming
Cover | Introduction | Basics | Classes | Advanced Topics | The .NET Framework | Index
Cover | Introduction | Basics | Classes | Advanced Topics | The .NET Framework | Index
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) |