by Administrator
18. May 2009 16:56
A statement is a command that performs an action. You combine statements to create
methods. “Writing Methods and Applying
Scope,” but for now, think of a method as a named sequence of statements. Main, which was
introduced in the previous chapter, is an example of a method. Statements in C# follow a
well-defi ned set of rules describing their format and construction. These rules are collectively
known as syntax. (In contrast, the specifi cation of what statements do is collectively known as
semantics.) One of the simplest and most important C# syntax rules states that you must terminate
all statements with a semicolon. For example, without its terminating semicolon, the
following statement won’t compile:
Console.WriteLine(“Hello World”);
The trick to programming well in any language is learning the syntax and semantics of the
language and then using the language in a natural and idiomatic way. This approach makes
your programs more easily maintainable. In the chapters throughout this book, you’ll see
examples of the most important C# statements.
C# is a “free format” language, which means that white space, such as a space character or a
newline, is not signifi cant except as a separator. In other words, you are free to lay out your statements
in any style you choose. However, you should adopt a simple, consistent layout style and
keep to it to make your programs easier to read and understand.

96065be0-d9fe-40b4-83ae-98a12a8cf109|0|.0
Tags: c#