how to call base implementation of method from base

  • Thread starter Thread starter John Rivers
  • Start date Start date
J

John Rivers

is there a way to invoke the (local?) base implementation of a virtual
method from the same class?

class A {
protected virtual void Blah() {
throw new Exception("never hits here");
}
public void Fud() {
this.Blah(); // hmmm invokes most derived // same as Blah();
}
}

class B : A {
protected override void Blah() {
// stuff
Fud();
// more stuff
}
}
 
is there a way to invoke the (local?) base implementation of a virtual
method from the same class?

No. You have to provide alternate access to the base method if you really
need to call it. More than likely, though, this is a flag that you need to
re-think your design.
 
No. You have to provide alternate access to the base method if you really
need to call it. More than likely, though, this is a flag that you need to
re-think your design.

It is easy enough to move behaviour into a non-virtual method
it just seemed strange to have a syntax that didn't behave as it read

Blah() is no different to this.Blah()
but in derived class this.Blah() and base.Blah() are very different
 
Back
Top