Information Technology Reference
In-Depth Information
Flow-of-Control Statements
C# provides the flow-of-control constructs common to modern programming languages.
￿
Conditional execution executes or skips a section of code depending on a condition. The
conditional execution statements are the following:
- if
- if...else
- switch
￿
Looping constructs execute a section of code multiple times, where the number of times
depends on the changing state of the program. The looping statements are the
following:
- while
- do
- for
- foreach
￿
Jump statements change the flow of control from one section of code to a specific state-
ment in another section of code. The jump statements are the following:
- break
- continue
- return
- goto
- throw
Conditional execution and looping constructs (other than foreach ) require a test expres-
sion, or condition , to determine where the program should continue execution.
Note Unlike C and C++, test expressions must return a value of type bool . Numbers do not have a
Boolean interpretation in C#.
Search WWH ::




Custom Search