What does the keyword virtual mean in the method definition?

Answers were Sorted based on User's Feedback



What does the keyword virtual mean in the method definition?..

Answer / venu gopal

The method can be over-ridden.

Is This Answer Correct ?    16 Yes 2 No

What does the keyword virtual mean in the method definition?..

Answer / 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

What does the keyword virtual mean in the method definition?..

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

Post New Answer

More C Sharp Interview Questions

What are the properties of string?

0 Answers  


Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve ?

1 Answers  


How can we sort an array in c#?

0 Answers  


How can you clean up objects holding resources from within the code?

2 Answers   L&T, Wipro,


What are expressions c#?

0 Answers  






Can a struct have a default constructor (a constructor without parameters) or a destructor in c#?

0 Answers  


Hai I am Shiva from TN, SSE.I have an query problem. My Table : Door Field : ID,DoorID,ZoneID,Date,Time,Status. Problem was : Status.We got two values, one is 00 (OUTTIME) , Another is 01(INTIME) Like this Status --------- 00 01 00 01 00 01 00 01 How to Set as Status 00 and 01 , of separate column , Status as Intime,Status as Outtime Like this ----------- InTime OutTime ---------- ----------- 01 00 01 00 01 00 01 00 01 00 01 00 Regards KS kumar

1 Answers  


What is dictionary and hashtable in c#?

0 Answers  


When a new instance of a type is created, what is the type of method implicitly called?

2 Answers  


List the fundamental oop concepts?

0 Answers  


What is lazy in c#?

0 Answers  


What is the difference between String s(Small s) and String S(Capital S)?

4 Answers  


Categories