Statements

As a derivation of C and C++, C# borrows most of its statements from these two languages. The next section outlines the statements found in C# and their usage.

Blocks

A block statement allows multiple statements to be written in contexts where a single statement is allowed. A block statement consists of a statement list enclosed by braces:

\
static void main
{

}

Statement Lists

A statement list is simply one or more statements written in sequence and enclosed in blocks as outlined in the preceding section:

static void main
{
    refresh();
    repaint();
}

Empty Statement

An empty statement performs no operations and is used where a statement is required, as in this while loop with a null body:

while (x > 0)
{
    ;
}

Labeled

A labeled statement ...

Get ASP.NET by Example 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.