Create an event to watch for a change of variable
问题 Let's just say that I have: public Boolean booleanValue; public bool someMethod(string value) { // Do some work in here. return booleanValue = true; } How can I create an event handler that fires up when the booleanValue has changed? Is it possible? 回答1: Avoid using public fields as a rule in general. Try to keep them private as much as you can. Then, you can use a wrapper property firing your event. See the example: class Foo { Boolean _booleanValue; public bool BooleanValue { get { return