I have got the following class structure, and have plenty of classes like C derived from B, in some of the classes I dont want by B.OnShow() but I want A.OnShow() to be executed from C Any tricks?
abstract class A
{
protected virtual void OnShow()
{
//some code
base.OnShow();
}
}
class B : A
{
protected override void OnShow()
{
//some other code
base.OnShow();
}
}
class C : B
{
protected override void OnShow()
{
//some other code
base.OnShow();
}
}
Don't have C extend from B, instead make a new class "X" that extends from A and has the parts that are currently in B that you want for both B and C and then have C and B extend from "X". Then B will just have the bits in it that you want for B specifically (a bit abstract, but I think that makes sense).
Generally speaking, if you are trying to skip a parent method then you are doing something wrong.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With