What is the difference between an abstract and a virtual method?

A nice and easy to understand explanation that I have found in stackoverflow :

An abstract method cannot have functionality. You’re basically saying, any child class MUST give their own version of this method, however it’s too general to even try to implement in the parent class.

A virtual method, is basically saying look, here’s the functionality that may or may not be good enough for the child class. So if it is good enough, use this method, if not, then override me, and provide your own functionality.

p.s.  if you override a virtual method, you can always refer to the parent method by calling base

 

 

 

Giorgos Basagiannis

I am a full stack engineer with broad technical skill set. I am passionate about developing high quality software that is scalable and easy to maintain. My main areas of interest include Microsoft Web & Cloud Technologies,JavaScript based frameworks,SharePoint and Office 365.

Leave a Reply

Your email address will not be published. Required fields are marked *