, B.Method2. , , :
((A)B).Method2();
B.Method2();
B.Method1(), . Method1, .Method1(), B ( , B.Method1).
, , B :
class B:A {
new public void Method1() { }
... then A Method1 () will be called because method 1 was not actually overridden, it was hidden and hidden outside the rules of polymorphism. In general, this is usually bad. Not always, but make sure that you know very well what you are doing and why you are doing it if you ever do something like this.
On the other hand, using the new in this way also creates interesting interesting questions.
source
share