Changes

Jump to: navigation, search

The C Sharp switch Statement

307 bytes added, 20:41, 16 January 2008
Using the C# goto and continue statements
Whilst the ''goto'' statement can be used to jump to any labeled location its use is strongly discouraged. The use outlined above is really the only acceptable use of the ''goto'' statement in a modern object oriented language. As any veteran programmer will tell you, if you find yourself in a position where a ''goto'' statement is your only way of achieving something then you need to re-think and re-structure your code so that you no longer need the ''goto''.
 
Another alternative to the ''break'' statement is the ''continue'' statement. If the ''switch'' statement is part of a loop, the ''continue'' statement will cause execution to return immediately to the beginning of the loop, by passing any subsequent code yet to be executed in the current loop iteration.

Navigation menu