why methods in every service is made virtual??

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 years ago
why methods in every service is made virtual like below:

 public partial class CategoryService : ICategoryService
    {
   public virtual void DeleteCategory(Category category)
        {
         }
     }


what is the difference if virtual keyword is removed and virtual keyword is kept??

and i have notice every utilities on controller even are virtual and protected.shouldnt it be private instead on protected???

  
protected virtual IEnumerable<ProductOverviewModel> PrepareProductOverviewModels()
        {
        }


Can anybody explain me this??
9 years ago
To allow sub-classes to override the methods... :)
9 years ago
Have a look at MSDN about virtual

https://msdn.microsoft.com/en-us/library/9fkccyh4.aspx


You should also read about OOP or polymorphism.

http://stackoverflow.com/questions/1031273/what-is-polymorphism-what-is-it-for-and-how-is-it-used
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.