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 returned if you pass the value 12.34 to the parsefloat () function?
What is the difference between proc. Sent by val and by sub?
How to sort an int array in c#?
What are the benefits of using generics?
Distinguish between a class and struct?
Which class does the remote object has to inherit?
Explain hash table in c# ?
What does type safe mean in c#?
What is the interface in c#?
Why do we need abstract class?
What operator means?
What is dictionary and hashtable in c#?
Why generics are used in c#?
Explain how obfuscator works in .net
List down the reason behind the usage of c# language.