Changes

Jump to: navigation, search

The Windows PowerShell 1.0 switch Statement

38 bytes added, 16:54, 3 December 2008
Windows PowerShell switch Statement Syntax
In the above syntax outline ''value'' represents either a value, or an expression which returns a value. This is the value against which the ''switch'' operates. Using our example this would be the string representing the car model.
For each possible match a ''<pattern>'' is required. This can either be a single value against which the comparison is made, a wildard, regular expression or an any other expression. Following on from the case line lines are the Windows PowerShell statements which are to be executed in the event of the pattern match or expression evaluating to be ''true''.
After the ''statements'' comes an optional ''break'' or ''continue'' statement. These statements are used either to break out of the ''switch'' statement when a match is found, or skip any remaining code in a loop and begin the next iteration. If a ''break'' or ''continue'' is not specified, the switch statement will continue to work through any remaining cases even when a match has been found.

Navigation menu