switch Statement
The switch statement selects one of many code blocks to execute.
int day = 3;string dayName;switch (day){ case 1: dayName = "Monday"; break; case 2: dayName = "Tuesday"; break; case 3: dayName = "Wednesday"; break; default: dayName = "Unknown"; break;}Console.WriteLine(dayName);Run the Application
Section titled “Run the Application”dotnet runResult
Section titled “Result”Wednesday