Using inheritance in C#
In today's world, inheritance is usually associated with the end of things. In OOP, however, it is associated with the beginning of something new and better. When we create a new class, we can take an already existing class and have our new class inherit from it. This means that our new object will have all the features of the inherited class, as well as the additional features added to the new class. This is at the root of inheritance. We call a class that inherits from another a derived class.
Getting ready
To illustrate the concept of inheritance, we will create a few classes that inherit from another to form new, more feature-rich objects.
How to do it…
- Create a new class library by right-clicking on your solution and selecting Add and then New Project from the context menu:
- From the Add New Project dialog screen, select Class Library from the installed templates and call your class
Chapter3
: - Your new class library will be added to your solution with a...