Reputation: 115
int i = 0;
When i
value changes:
i = (Atypical value)
then
bool callback(int i)
target = i;
return true;
In C#, How to get the value of a variable when it changes Without using threads or timers
Upvotes: 7
Views: 220
Reputation: 9795
Use a property:
private int _i = 0;
public int i
{
get { return _i; }
set
{
if (_i == value) { return; }
_i = value;
callback(value);
}
}
Upvotes: 11