you can use generic class:
class Wrapped<T> {
private T _value;
public Action ValueChanged;
public T Value
{
get => _value;
set
{
_value = value;
OnValueChanged();
}
}
protected virtual void OnValueChanged() => ValueChanged?.Invoke() ;
}
and will be able to do the following:
var i = new Wrapped<int>();
i.ValueChanged += () => { Console.WriteLine("changed!"); };
i.Value = 10;
i.Value = 10;
i.Value = 10;
i.Value = 10;
Console.ReadKey();
result:
changed!
changed!
changed!
changed!
changed!
changed!
changed!