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 the delegates in c#?
How to find methods of a assembly file (not using ILDASM)?
What is out int in c#?
What is a console operator?
Is string nullable in c#?
When should we use sealed class in c#?
Can var be null c#?
What is xor operator in c#?
What is the difference between interface and abstract class in c#?
Is it possible to have a static indexer in c#?
What is task parallel library?
explain the nature of the assembly work?
What is a dictionary in c#?
When can a derived class override a base class member?
What is difference between Trace and Debug