What is the difference between overriding and hiding in C#?

CsharpProgrammingServer Side Programming

Method hiding is also called shadowing in C#. The method of the parent class is available to the child class without using the override keyword in shadowing. The child class has its own version of the same function.

Define a behavior that is specific to the subclass type in overriding, you, which means a subclass can implement a parent class method based on its requirement.

Hiding redefines the complete method, whereas overriding redefines only the implementation of the method.

In Overriding, you can access the base class using the child class’ object overridden method.. Shadowing has cannot access the child class methods.

raja
Published on 16-Aug-2018 15:31:08
Advertisements