types of inheritance in c# code example

Example 1: c# class inheritance constructor

public otherclass{

    public otherclass(a,b){
          a=0;
          b=1;
    }

}

public baseClass : otherclass{
  
  	public baseClass(string str,int a, int b): base(a,b){
    	str="whatever";
    }
  
}

Example 2: c# inheritance

class parent_class
{
  
}
class child_class : parent_class
{
//Will simply move Data and Methods from the parent_class to the child class.
}

Example 3: inheritance in c#

// Parent Class
public class A
{
    public void Method1()
    {
        // Method implementation.
    }
}
// inherit class A in class B , which makes B the child class of A
public class B : A
{ }

public class Example
{
    public static void Main()
    {
        B b = new B();
        // It will call the parent class method 
        b.Method1();
    }
}