Statements

In C#, a complete program instruction is called a statement. Programs consist of sequences of C# statements, each of which must end with a semicolon (;). Here are three statements:

int myVariable;                      // a statement
myVariable = 23;                     // another statement
int anotherVariable = myVariable;    // yet another statement

C# statements are evaluated in order. The compiler starts at the beginning of a statement list and makes its way to the bottom. This would be entirely straightforward, and terribly limiting, were it not for branching. Branching allows you to change the order in which statements are evaluated. See Chapter 6 for more information about branching.

Get Learning C# 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.