Introduction:
Inheritance is a concept of object oriented programming, in which a sub class or a child class inherits the super class or the parent class and it then the access the variables or the methods defined inside that particular class. In this process a child class can have access to the public or protected variables and methods of the parent class or the base class.
Step 1:
In this example we will learn how does Inheritance takes place in c#, so first up create new a project in visual studio 2017, We will name it as InheritanceBasics and click OK.
Step 2: We will create a base class and we will define a few data members along with methods inside the base class.
So here we created an object for the child class Derived and we called the two methods of the base class first to set the width and height of the circle and finally it calls the function AreaofCircle(), which returns the area of a circle.
Here is how the entire code looks like.
Press crtl+f5 to run the program and see the output window.