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

Can an int be negative c#?

585


What is double c#?

533


Can you declare a field readonly?

542


Why singleton pattern is used in c#?

538


How do you escape in c#?

506






How to find methods of a assembly file (not using ILDASM)?

646


What is sqladapter c#?

532


How can I make sure my c# classes will interoperate with other .net languages?

529


What is type keyword in c#?

532


what is the difference between convert.tostring() and tostring() functions ?

579


What is arraylist?

542


Why do we use interfaces in c#?

496


What is the use of list in c#?

475


What is lazy class in c#?

481


To create a localized application which namespaces are necessary?

525