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 an inheritance ?Give an example in which inheritance is used?

521


Explain the access modifiers in c#?

484


Name the control which cannot be placed in mdi?

490


Why do we need a singleton class?

496


Can fields inside a class be virtual?

529






Can we inherit private members of class in c#?

575


what are nullable types in c#

518


What is event delegate in c#?

573


What Is An Interface Class?

554


What is difference between private and protected?

493


What are methods c#?

480


What is oledb in c#?

494


Is multiple inheritance possible in c#?

551


What is binding in c#?

481


What is string concatenation?

471