1.5 Statements
The actions of a program are expressed using statements. C# supports several kinds of
statements, a number of which are defined in terms of embedded statements.
A block permits multiple statements to be written in contexts where a single statement is
allowed. A block consists of a list of statements written between the delimiters { and }.
Declaration statements are used to declare local variables and constants.
Expression statements are used to evaluate expressions. Expressions that can be used as
statements include method invocations, object allocations using the new operator, assignments
using = and the compound assignment operators, and increment and decrement
operations using the ++ and -- operators.
Selection statements are used to select one of a number of possible statements for
execution based on the value of some expression. In this group are the if and switch
statements.
Iteration statements are used to repeatedly execute an embedded statement. In this group
are the while, do, for, and foreach statements.
Jump statements are used to transfer control. In this group are the break, continue, goto,
throw, return, and yield statements.
Partager