First of all, there is no such thing as child class. The relationship can be "base class (ancestor) — derived class"). It is also called "generalization".
The keyword "new" is important to avoid compilation warning related to the fact that you hide some member of the base class. Consider this:
class Base {
internal virtual void Shaded() {}
}
class Derived : Base {
internal new void Shaded() { }
}
[EDIT: to prove my point in a little argument with Pete, please see his answer]
Exact same thing is valid if the method in a base class is
abstract
:
abstract class Base {
internal abstract void Shaded();
}
abstract class Derived : Base {
internal new void Shaded() {}
}
[END EDIT]
If you remove
new
, the warning is: "Warning 2 'Derived.Shaded()' hides inherited member 'Base.Shaded()'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
By saying
new
you say: "Yes, I hide the member, but not accidentally. I know what I'm doing. Don't worry, comrade compiler, I'll be just fine without your silly warning!"
Needless to say, it should be best avoided in most cases (which do exist). It's even better not to mess up with
virtual
(as shown above), but it principle this is possible.
Now, if you remove
virtual
from
Base.Shaded
or add virtual to
Derived.Shaded
, the effect will be the same. In these cases, nothing object-oriented happens. The only object-oriented effect (late binding) is possible when first method is marked
virtual
or
abstract
, and the second one —
override
. Then the dynamic dispatch of the call happens even if you
compile-time type is
Base
.
That comes to your last question. The answer is: no.
—SA