This chapter consists of two main parts. The first part is about the lexical structure of a C# source program. The second part provides an example of an object-oriented program, which relates directly to the discussion in Chapter 3 about abstraction and encapsulation.
The following are the most important points covered in this chapter:
A C# source program can be viewed as a collection of identifiers, keywords, whitespace, comments, literals, operators, and separators.
C# is a case-sensitive language. To improve the clarity for other readers of the code, it is important to adhere to a certain capitalization style. Pascal Casing (ThisIsPascalCasing) and Camel Casing (thisIsCamelCasing) are the preferred styles and are used for different C# constructs.
A literal has the value that is written in the source code (what you see is what you get). Values like 10 and "This is a dog" are examples of literals.
Separators, such as semicolons (;), commas (,), and periods (.), separate different elements in C# from each other.
Operators act on operands. Operands combine with operators to form expressions.
Instance variables must be initialized when an object is created. This is either done automatically by the runtime, by a declaration initialization, or by an instance constructor.
An object can hold a reference to another object in an instance variable. Such a permanent relationship is called an association.
An object is created by using the new keyword.
In an object-oriented program, classes collaborate to provide the functionality of the program.
Two classes can collaborate by having a relationship.
Common association relationships are aggregations and compositions.
The Unified Modeling Language (UML) is by far the most popular graphical modeling language used to express and illustrate object-oriented program designs.