C# Switch Statements

tutorial and example
tutorial and example

In C#, the switch case statement checks one variable for various possible values (cases) and executes the case which is true. Switch case statements are mainly used in menu driven programs where various choices are thrown to user out of which 1 is to be chosen.

Syntax

C# switch case Example:

Output

Note:

  1. We can’t use two parameters in switch statement.
  2. The case value must be an integer.