Running additional code with auto property setter

Viewed 787

Is it possible to run additional code in the setter, only using auto implemented properties? I.e. something like this, just using auto properties:

// I Would like to get rid of this...
int privateField 

// ...and only have this
public int PrivateField 
{
    get { return privateField; }
    set
    {
        privateField = value;
        functionDependingOnSetter(value);
    }
}

(in case it is not clear, I want the function functionDependingOnSetter() to run, whenever the property setter is called).

0 Answers
Related