Overriding
using System;
//Method overriding is the process by which a derived class rewrites a method of the base class with the same signature,thus hiding the baseclass method.
class BaseClass
{
void display()
{
Console.WriteLine("display function within base class");
}
}
class ChildClass : BaseClass
{
void display() // display function within base class is overridden here
{
Console.WriteLine("display function within child class");
}
static void Main(string[] args)
{
Console.WriteLine("Example of overriding");
ChildClass ch = new ChildClass();
ch.display();
Console.ReadLine();
}
}
Output:
Example of overriding
display function within child class