inheritance Definition and Types in c#
In C#, it is possible to inherit fields and methods from one class to another. We group the "inheritance concept" into two categories:
Derived Class (child) - the class that inherits from another class
Base Class (parent) - the class being inherited from
what is inheritance in c#:
Inheritance is one of the fundamental attributes of object-oriented programming. It allows you to define a child class that reuses (inherits), extends, or modifies the behavior of a parent class. The class whose members are inherited is called the base class.
Types of inheritance in c#
1. Single inheritance in C#
It is the type of inheritance in which there is one base class and one derived class.
2. Hierarchical inheritance in C#
This is the type of inheritance in which there are multiple classes derived from one base class. This type of inheritance is used when there is a requirement of one class feature that is needed in multiple classes.
3.Multilevel inheritance in C#
When one class is derived from another, this type of inheritance is called multilevel inheritance.
4.Multiple inheritances using Interfaces
C# does not support multiple inheritances of classes. To overcome this problem, we can use interfaces. We will see more about interfaces in my next article in detail.
No comments:
Post a Comment