Click here to Skip to main content
15,914,010 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
What is the difference between abstract and virtual?
Posted
Comments
Richard MacCutchan 8-Nov-11 5:14am    
Your questions are abstract and you are a virtual pain!

In some cases you cannot provide a implementation for some methods, but
method have to be there because it is part of the class interface. You want
the programmers using the class to provide this implementation and you don't
want to let them instantiate objects of this class because without this
method it won't simply work. In this case you declare the method and the
class as abstract. Abstract classes cannot be instantiated because they are
not complete.


In other cases you can provide a default implementation of a method which is
good enough to make the control work even if not re-defined, but you want to
give the programmers using your class as a base class to provide their
better implementation. In this case you declare the method as virtual thus,
giving the progammers options whether to use the default or provide their
own eomplementation or if they which to use the default and tweak the
results.


for more info visit this
http://stackoverflow.com/questions/755285/abstract-methods-vs-virtual-methods-in-c-sharp

http://msdn.microsoft.com/en-us/library/6tcf2h8w(v=VS.71).aspx[^]
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900