1.11. Loops and Other Flow of Control Structures

Very rarely will a program execute sequentially, line by line, from start to finish. Instead, the execution flow of the program will be conditional. It might be necessary to have the program execute a certain block of code if a condition is met or another block of code if the condition isn't met. A program might have to repeatedly execute the same block of code. The C# language provides a number of different types of loops and other flow of control structures to take care of these situations.

1.11.1. if Statements

The if statement is a basic conditional branch statement that executes one or more lines of code if a condition, represented as a logical expression, is satisfied. Alternatively, one ...

Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.