...

/

Switch Statements

Switch Statements

This lesson discusses switch statements in C# using an example

Switch Case

Typically this is required when based on different values of a particular expression, different actions need to be performed. The basic construct of a switch case looks as follows:

switch (expression)
{
case constant-expression:
statement
jump-statement
default:
statement
jump-statement
}
  • In code block above the expression can have multiple values. Essentially:

    • string
    • integer
  • case section with constant-expression can have the value as

...