switch statement

A statement that compares one value against a list of cases and runs the matching branch, with a default for everything else.

In more detail

Each case usually ends with break or return; some languages, such as JavaScript, fall through into the next case otherwise, while C# forbids it. To choose a value rather than run steps, a switch expression is often shorter.

Related terms

Taught in

References