O'Reilly logo

ASP.NET by Example by Steven A. Smith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required