Virtual Key word

Posted by Bravi under C# on 9/17/2009 | Views : 2330 | Status : [Member] | Replies : 2
if we create a virtual class and i am not override that class . what will happed whether it give compile time error or runtime error ..




Responses

Posted by: Rtpharry on: 9/17/2009 [Member] [MVP] Bronze

Up
0
Down
Ok this one took a bit of Googling :)

My references:
http://msdn.microsoft.com/en-us/library/9fkccyh4.aspx
http://en.wikipedia.org/wiki/Virtual_function#Java_.28and_C.23.29


If you set a method as virtual you still have to provide the code for that method in the base class. It is optional to override it in the derived class. If you dont override it then the base class will be used instead.

If you dont want to provide an implementation for the method then you can mark it as abstract. This is also known as a pure virtual method.

Bravi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kalyaninalluri on: 10/5/2009 [Member] Bronze

Up
0
Down
This keyword indicates that a member can be overridden in a child class. It can be applied to methods, properties, indexes and events.


Bravi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response