Method Hiding & Method Shadowing
Method Hiding / Method Shadowing is a feature of C# that enables you to hide base class methods from derived classes.
Then main purpose of shadowing is to protect the definition of your class memebers.
In method hiding, you can hide the implementation of the methods of a base class from the derived class.
Shadowing Through Scope
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.
Use the new keyword to perform shadowing and to create the own version of the base class function.
Shadowing through Inheritance / Overriding
Under
overriding, you can define a behavior that's specific to the subclass
type, which means a subclass can implement a parent class method based
on its requirement.
Call the hidden method of the base class in the derived class
In method hiding, you can also call the hidden method of the base class in the derived class using three different ways and the ways are:
1. By using the base keyword you can call the hidden method of the base class in your derived class
2. By casting the derived class type to base class type
3. Use the parent class reference variable for calling the hidden method.