Simple Inheritance
using System;
// When a single derived class is created from a single base class then the inheritance is called as single inheritance.
class Class1
{
public void display1()
{
Console.WriteLine("display of Class1");
}
}
class Class2 : Class1 // Now Class2 contains all the public members of Class1 through simple inheritance.
{
public void display2()
{
Console.WriteLine("display of Class2");
}
static void Main(string[] args)
{
Class2 c2 = new Class2();
c2.display1();
c2.display2();
Console.ReadLine();
}
}
Output:
display of Class1
display of Class2