Runtime polymorphism/Overriding with example program cod in a c# code
Runtime polymorphism/Overriding with example program cod in a c# code
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jul 10, 2012, 11:10 AM
Virtual & Override keywords provides runtime polymorphism. A base class can make some of its methods as virtual which allows the derived class a chance to override the base class implementation by using override keyword.
For e.g. class Shape
{
int a
public virtual void Display()
{
Console.WriteLine("Shape");
}
}
class Rectangle:Shape
{
public override void Display()
{
Console.WriteLine("Derived");
}
}
Thanks