how to call base implementation of method from base

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
}
}
 
J

Jeff Johnson

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.
 
J

John Rivers

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top