Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is difference between method overriding and method hiding in c#, explain with example?

user-image
Question added by Mukhtar Ahmad
Date Posted: 2014/08/20
Zubair Ali
by Zubair Ali , Software Developer III , S&P Global

Common thing is that you create a method with same signature in Base and the child class. but both have a distinction of Keyword Virtual and Override used with Base class and the child one respectively.If you just write a method in base class and in the child also with the same name then it is an example of method hiding. but if you make your method virtual in base class and override it in child class with DISTINCT implementation in child then its an example of Method Overriding. 

Dileep DK
by Dileep DK , Head of Engineering – Consumer Finance , DBS Bank Ltd.

Overriding and hiding are very similar but the differences are in the scope. When overriding you still get to access the base methods whereas while hiding you have to implement all methods.

More Questions Like This