laxman2jasmi wrote:
In an inheritance relationship, which one of the following methods is most likely to be virtual?
when u have a function in your class which you want to be implemented by the inherited class you can use the virtual function, hers a code for demonstration
using System;
class parent
{
public virtual void myfunction()
{
Console.WriteLine("Hi i am virtual function");
}
}
class child: parent
{
public override void myfunction()
{
Console.WriteLine("I am Legend");
}
public virtual void hellboy()
{
Console.WriteLine("My name is Hellboy");
}
}
class Radixx :child
{
public override void hellboy()
{
Console.WriteLine("My name is Radix and i am a programmer");
}
}
class implement
{
public void cl(parent p)
{
p.myfunction();
}
public void arsenal(Radixx rad)
{
rad.hellboy();
}
}
class calling
{
static void Main()
{
implement obj = new implement();
child radix = new child();
obj.cl(radix);
Radixx rdx = new Radixx();
obj.arsenal(rdx);
}
}
Do rate my answer once you find it useful
Thanks & Regards
Radix :rose: