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 |
What is the difference between System.console.WriteLine() and System.console.Write() function?example?
How u call destructor and dispose methode in c#.NET
What do you mean by parsing and how to parse a date time string in c#?
What is the use of constructor in c# with example?
Why c# is type safe?
What is Implicit conversion in C#?
What is the difference between Object and class adapters?
What is multithreading with .net?
Will finally block get executed if the exception had not occurred?
Give examples for value types?
What is a property c#?
Explain how do you convert a value-type to a reference-type?