Notify in derived class when a property has changed in the base class
14:27 08 Aug 2015

I want to execute some code on derived Form whenever a specific property changes in the base Form.

A form implements some common stuff on forms (skinning, etc.)

Example:

abstract class A
{
    private bool _value;

    public abstract void Execute();

    public A()
    {
        _value = false;
    }

    public bool Value
    {
        get
        {
            return _value;
        }
        set
        {
            _value = value;

            if (value)
            {
                Execute();
            }
        }
    }
}

class B : A
{
    public B()
    {

    }

    public override void Excute()
    {
        // Do some stuff here
    }
}

I have been dealing with abstract methods, but I cannot figure how to solve it.

If I declare A as abstract I cannot open B in the designer.

In fact, the real code is a bit more complex, because I have an A base class (a form with the common functions) and B, C, D which are derived forms more specific: B with button navigation, C for special forms, etc. So when I create a form in my application, I must inherit from B, or C, ...

Thanks for your help

c# class derived-class base-class