What does the keyword virtual mean in the method definition?
Answers were Sorted based on User's Feedback
Even though the function in base class is declared with
virtual keyword, it is not compulsory that the derived
class must override it.
namespace TestNewOverride
{
class MyBaseClass
{
int a;
public virtual int doubleit()
{
return 2 * a;
}
public MyBaseClass()
{
a = 5;
}
}
class MyDerivedClass:MyBaseClass
{
public static void Main()
{
}
}
}
Is This Answer Correct ? | 7 Yes | 0 No |
Answer / praseetha sandeep
when you have a method defined in a class which you want
to allow to be implimented by inherited class you can use
virtual function
Is This Answer Correct ? | 4 Yes | 0 No |
If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor?
What is the use of tuple in c#?
What is strong name assembly?
who is a protected class-level variable available to?
Is learning c# hard?
What is the difference between “out” and “ref” parameters in c#?
What are the important concepts in OOPS
What is the difference between field and property in c#?
How many types of variables are there in c#?
What is the use of command builder?
What is thread life cycle in c#?
Difference between StackPanel and RelativePanel ?