Statements

In C#, a complete program instruction is called a statement and each statement ends with a semicolon (;). Forgetting a semicolon is a very common mistake for novice programmers, but Visual Studio will catch you if you do it. Programs consist of sequences of statements, such as the following:

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

The compiler starts at the beginning of a source code file and reads downward, executing each statement in the order in which the compiler encounters it. 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, and even take different paths depending on the value of your variables, but let’s not get ahead of ourselves. We’ll get to branching in Chapter 5.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset