What’s in This Chapter
Wrox.com Downloads for This Chapter
Please note that all the code examples for this chapter are available as a part of this chapter’s code download on the book’s website at www.wrox.com/go/csharp5programmersref on the Download Code tab.
This chapter describes the basic concepts behind object-oriented programming (OOP). It explains how to define classes and how to derive one class from another. It also describes the three fundamental features of OOP programming languages: encapsulation, inheritance, and polymorphism. It explains how C# provides those features and what benefits you can gain from using them properly.
A class is a programming entity that packages the data and behavior of some sort of programming abstraction. It encapsulates the idea that it represents in a package that has a well-defined interface to code that lies outside of the package. The interface determines how other pieces of code can interact with objects defined by the class. The interface determines which pieces of data are visible outside of the class and which pieces of data are hidden inside the class.
The three main sets of characteristics of a class are the properties, methods, and events that it defines. The public (externally visible) properties, methods, and events let the program work with the ...