Using Closures to keep track of a variable: Good idea or dirty trick?
问题 Ok, i have a need to be able to keep track of value type objects which are properties on another object, which cannot be done without having those properties implement an IObservable interface or similar. Then i thought of closures and the famous example from Jon Skeet and how that prints out 9 (or 10) a bunch of times and not an ascending order of numbers. So i thought why not do this: Class MyClass { ... Func<MyValueType> variable; ... public void DoSomethingThatGetsCalledOften() {