Please see my comment to the question. Asking "why" makes little to no sense.
I think by "shading" you mean something more correctly called "hiding". "Shading" is just a pretty misleading word some use. See by yourself.
First of all, you should understand that hiding is not any useful OOP concept. It does not even related to the essence of OOP. Rather, it is a by-product of the syntax related to what I call one of the prerequisites to "real" OOP,
inheritance. Let's see. All members of a base class are inherited by a derived class. What happens if someone, by one or another reason, creates some member in the derived class, with the same name, type/signature as some existed, inherited member?
There can be different approaches to this situation. The simplest solution would be prohibiting this. But, traditionally, it is allowed. In C#, just the warning is issued; and it can be suppressed. For example:
class Base {
internal void SomeMethod();
}
class Derived : Base {
internal void SomeMethod();
}
In what sense does it hide the method? Let's see the usage:
Derived derived = new Derived();
derived.SomeMethod();
Base base = derived;
base.SomeMethod();
Note that
runtime type of
derived
is
Derived
, and its
compile-time type used to call the hidden method in the last line is
Base
.
The hiding can be considered as the result of someone's mistake. There is nothing useful in it, but the way it works allows for the work-around I just demonstrated.
And this is how the warning is suppressed:
class Derived : Base {
internal new void SomeMethod();
}
Good luck.
—SA