About Virtual functions and their use ?
Answer Posted / deepak jindal
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
}
}
| Is This Answer Correct ? | 14 Yes | 3 No |
Post New Answer View All Answers
What is a c sharp?
what are pointer types in c#
Why are local variables stored in stack?
What is the namespace for the thread class?
How many digits is a 32 bit number?
Explain the feature of c# language?
Why we use get set in c#?
What are the principles of delegation?
How do I stop my console from closing in c#?
Give an example to show for hiding base class methods?
What is dictionary class in c#?
What is bit in c#?
What do you mean by winforms in c#?
How do you type a null character?
What is an assembly in .net?