Chapter 3, "Objects and Types," examined how to use individual classes in C#. The focus in that chapter was on how to define methods, constructors, properties, and other members of a single class (or a single struct). Although you did learn that all classes ultimately derive from the class
System.Object, you did not see how to create a hierarchy of inherited classes. Inheritance is the subject of this chapter. It briefly discusses the scope of C#'s support for inheritance before examining in detail how to code first implementation inheritance and then interface inheritance in C#. Note that this chapter presumes familiarity with the basic concepts of inheritance, including virtual functions and overriding. This chapter concentrates on the syntax used to provide inheritance and inheritance-related topics, such as virtual functions, and on those aspects of the C# inheritance model that are particular to C# and not necessarily shared by other object-oriented languages.
This chapter starts off by reviewing exactly what C# does and does not support as far as inheritance is concerned.
Gurus of object-oriented programming will know that there are two distinct types of inheritance: implementation inheritance and interface inheritance.
Implementation inheritance means that a type derives from a base type, taking all the base type's member fields and functions. With implementation inheritance, a derived type ...