Execution of a C# program is specified by a series of statements that execute sequentially in the textual order in which they appear. All statements in a procedural-based language such as C# are executed for their effect. The two most basic kinds of statement in C# are the declaration and expression statements. C# also provides flow control statements for selection, looping and jumping. Finally C# provides statements for special purposes, such as locking memory or handling exceptions.
So that multiple statements can be grouped together, zero or more
statements may be enclosed in braces
}), to form a statement
statement block can be used anywhere a single statement is valid.
evaluates an expression either
assigning its result to a variable or generating side-effects, (i.e.,
--). An expression statement ends in a
;). For example:
x = 5 + 6; // assign result x++; // side effect y = Math.Min(x, 20); // side effect and assign result Math.Min (x, y); // discards result, but ok, there is a side effect x == y; // error, has no side effect, and does not assign result
Variable declaration syntax:
Constant declaration syntax:
A declaration statement declares a new variable. You can initialize a variable at the time of its declaration by optionally assigning ...