The switch-statement provides a more structured way of catching multiple conditions in a single block.
switch( )
{
case 0:
statement;
break;
case 1,2,3,4:
statement;
break;
case "hello", "world":
statement;
break;
default:
statement;
break;
}
|
The only 'disadvantage' of switch-statements is the need of constant values in the case-conditions. Apart from that you can use every (constant) type which is implicity convertible to the variable you want to evaluate.
|