What does the keyword virtual mean in the method definition?

Answer Posted / kiran

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is difference between private and static constructor?

652


Explain publishers and subscribers in events.

711


What does type safety mean?

798


Is c# an open source language?

740


What is a virtual property. Give an example?

696


What is the difference between serialization and deserialization in c#?

634


What is continue in c#?

713


What is Inheritance in C#?

766


What is null character in string?

732


What exactly is serverless?

593


Is nullable type c#?

682


What are the properties of c#?

678


What happens if the inherited interfaces have conflicting method names?

771


What is an Interface in C#?

722


What are mutable and immutable types in c#?

662