You will learn about the following in this chapter:
The different class members
static instance variables
The parameter array
The keyword this
Recall that a class provides a blueprint for creating an object, just like an architectural drawing specifies how to build a house. The class is an abstraction of a real-world (tangible or conceptual) object that belongs to, for our program, a relevant problem domain. A single class template can be used to create numerous objects (instances) that all share the features specified by this particular class.
In previous chapters, we saw how to solve several different computational problems by letting suitable objects of different classes collaborate, each contributing with its unique abilities. The class construct allows us to combine data (collectively referred to as the state of the object) with functions (representing the behavior of the object) to form useful objects that fit into our overall software design. So far, our classes have consisted of instance variables and methods as shown in Figure 12.1.
Class members are the language elements constituting the class body. Instance variables and methods are two fundamental class members, but because the classes we write as so diverse and via their objects interact in many different situations, C# contains several other class members that allow you to make each class more agile, intuitive and easier to use for other classes and programmers and tailor fitted for its particular role in a program. We will focus on these other class members in this and the next two chapters and also look more closely at important aspects of the method construct we have not yet discussed.