#333 – Class Inheritance Leads to a Hierarchy of Classes

Defining a new class, you can specify that it inherits data and behavior from any other existing class, or you can allow the new class to implicitly inherit from System.Object.  Because the new class can inherit from a class that itself inherits from another class, you end up defining a hierarchy of parent / child (base class / derived class) relationships.

Consider the picture shown below.  The user has defined a Dog class, which implicitly inherits from the predefined System.Object class.  They also define the Hound and Terrier classes, both of which inherit from Dog, as well as the FoxTerrier class, which inherits from Terrier.


A class inherits data and methods not only from its immediate parent, but also from other classes higher up in the inheritance chain.  For example, the FoxTerrier class inherits data and methods from Terrier, but also from the Dog class, as well as the System.Object class.