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 c-sharp (c#)?
Explain the types of comments in c#?
What is property in c#?
What is dynamic dispatch?
How can i Spawn a Thread
Why singleton class is sealed in c#?
What is verbatim string?
Why data types are important in c#?
Give an example of a ctype.
What is string in c# net?
Which programming language is best for desktop applications?
What is difference between ienumerable and list?
How do you set a class path?
write a C# Program add two matrix ?
What is sorted list in c#?