The Virtual is a keyword it used in the base class.When we
use the Virtual keyword in the function it must be override
in the inherited class with the same name.
If the instance function declared with a virtual modifier
then the function is called virtual function.
the derived class can give the redefinition to the virtual
function its optional.
Second answer given here is correct to some extent.
If we use Virtual keywork next to a mehtod,it can be
overridden in derived classes,but it is not must to
override.
Virtual Method are feature of object oriented programming
and used to Identify the Type of object that is calling any
particular method at the Run time so provides flexibility in
calling method.
when we override a metod in sub class,and we want to hide
the decelaration of the base class member then we used the
keyword virtual in superclass,
and keyword override in the subclass
If a base class method is to be overriden, It is defined
using virtual keyword. You need to use the override keyword
in order to re-implement the virtual method. Exp:
public class Employee
{
public virtual void SetBasic(float money) //This method may
be overriden
{ Basic += money; }
}
public class Manager : Employee
{
public override void SetBasic(float money) //This method is
being overriden
{
float managerIncentive = 10000;
base.SetSalary(money + managerIncentive); //Calling base
class method
}
}
what is diffrence between protected ,internal and protected
internal??
whether protected field available in derived class which is
outside the assembly.
if not ..this is possible by which access modifiers??
how to store the value in textbox using delegates if we have
two user control. the value will be called from one user
control to another user control. Loading and unloading will
be done through delegates.