O'Reilly logo

Professional C# 2005 by Allen Jones, Morgan Skinner, Karli Watson, Jay Glynn, Bill Evjen, Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Inheritance

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.

Types of Inheritance

This chapter starts off by reviewing exactly what C# does and does not support as far as inheritance is concerned.

Implementation Versus Interface Inheritance

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required