Working with simple inheritance in C#

First, we will create a base class in C#. Then we will use simple inheritance to create subclasses and specialize behavior. We will override methods and overload comparison operators to be able to compare different instances of a specific class and its subclasses. We will take advantage of this polymorphism.

Creating classes that specialize behavior in C#

Now it is time to code all the classes in C#. The following lines show the code for the Animal abstract class in C#. The class declaration doesn't specify a base class; therefore, this class inherits from Object, specifically System.Object. System.Object is the base class for all the classes included in .NET Framework. The usage of the abstract keyword before ...

Get Learning Object-Oriented Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.