Today in this article I will show you OOP concepts in the C# language.
I have updated this article on my personal blog. you can read it
Inheritance With Example in C#. Introduction
Real-world Example
A scientific calculator is an extended form of a calculator. Here calculator is the parent and scientific calculator is child object.
Programming Example
The process of acquiring the existing functionality of the parent and with the new added features and functionality of a child object.
What is Inheritance
Inheritance is one of the three foundational principles of Object-Oriented Programming (OOP) because it allows the creation of hierarchical classifications. Using inheritance you can create a general class that defines traits common to a set of related items. This class can then be inherited by other, more specific classes, each adding those things that are unique to it.
In the language of C#, a class that is inherited is called a base class. The class that does the inheriting is called the derived class. Therefore a derived class is a specialized version of a base class. It inherits all of the variables, methods, properties, and indexers defined by the base class and adds its own unique elements.
Inheritance Example
Diagram
The following diagram shows the inheritance of a shape class. Here the base class is Shape and the other classes are its child classes. In the following program we will explain the inheritance of the Triangle class from the Shape class.
Here are more articles on inheritance and object oriented programming in C#.
Types of Inheritance in C#
In this article, we will learn about C# inheritance and types of inheritance in C# and .NET with code examples.
Overview of Inheritance in C#
In this article, you will learn about inheritance in C#. Inheritance is one of the major pillars of object-oriented programming. Here is an overview of inheritance.
Multiple Inheritance in C#
Can you inherit from multiple classes in C#? Simply put, this cannot be done. However there are ways around it. From a design perspective you must ask yourself, will a Class fully represent an object?
Inheritance in C#
Interface inheritance defines a new interface in terms of one or more existing interfaces. Implementation inheritance defines a new implementation in terms of one or more existing implementations.