ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل Mukhtar Ahmad
تاريخ النشر: 2014/08/20
Zubair Ali
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة