C# programmin language – What is a virtual function? Give a complete code example as part of your response. Appropriate examples include the Doodle application done with the OnPaint method or any example that uses the OnPaint method or an ovveride of a function that does not exhibit polymorphic behavior.aaaaaaqqqqqqqqqqqqqqqq
Expert Answer
Example
public class ParentClass
{
public void display()
{
Console.WriteLine(“Hello World”);
}
public virtual void v_display()
{
Console.WriteLine(“Virtual in parent”);
}
}
public class ChildClass : ParentClass
{
public new void display()
{
Console.WriteLine(“Hi There”);
}
public override void v_display()
{
Console.WriteLine(“Overidden display”);
}
}
when an object of ChildClass is instantiated any call to v_display() will display Overidden Display