O'Reilly logo

Learning Object-Oriented Programming by Gastón C. Hillar

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

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

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