---
title: "What is inheritance?"  
description: "What is inheritance?"  
author: "Om ji mishra"  
published: 2019-10-14  
updated: 2019-10-14  
canonical: https://www.mindstick.com/forum/105413/what-is-inheritance  
category: "c#"  
tags: ["c#", "programming language"]  
reading_time: 2 minutes  

---

# What is inheritance?

What is [inheritance](https://www.mindstick.com/articles/13095/inheritance-and-its-types)?

## Replies

### Reply by Om ji mishra

Inheritance is an important pillar of oops. By using this property in C# we can use all features from the base class in any other classes. We can reuse the code by using inheritance.

Some important things about inheritance: -

- When we have to do inherit any class then we use " : " (colon)
- Syntax: - class <derived class name> : <base class name>
- We cannot inherit the private members, function, methods, etc.
- The class whose features are inherited is known as a super class (or a base class or a parent class)
- The class that inherits the other class is known as sub class (or a derived class, extended class, or child class)

```
Code: -
using System;
   public class Employee
    {
       public float salary = 40000;
   }
   public class Programmer: Employee
   {
       public float bonus = 10000;
   }
   class TestInheritance{
       public static void Main(string[] args)
        {
            Programmer p1 = new Programmer();
            float Total_Salary= p1.salary+p1.bonus;

            Console.WriteLine("Total Salary " + Total_Salary);

        }
    }
```

```
Code: -
using System;
namespace om
{

   public class Employee
    {
       public float salary = 40000;
   }
   public class bonusEmployee: Employee
   {
       public float bonus = 10000;
       public void Get_total()
       {
         float Total= base.salary+bonus;
         Console.WriteLine("Toatal salary {0}", Total);
       }
   }
   class TestInheritance{
       public static void Main(string[] args)
        {
          bonusEmployee p1 = new bonusEmployee();
          p1.Get_total();
        }
    }
}
```


---

Original Source: https://www.mindstick.com/forum/105413/what-is-inheritance

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
