Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
You make a property instead of a "variable" and inside the setter you call some method that will notify interested parties about the change.
For example like this:
public class Test {
private int _someValue;
public int SomeValue
{
get => _someValue;
set {
if(value != _someValue) {
_someValue = value;
NotifyAboutChange(); // То самое "действие"
}
}
}
}
To do this, an event is created: it is called by the method where the variable is used. Event subscribers receive information about the current value of the variable and execute their code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question