I just came across the most unexpected behavior. I\'m sure there is a good reason it works this way. Can someone help explain this?
Consider this code:
See Eric Lippert's blog post on this issue; it has to do with how iterator variables are scoped in code, and how that applies to lambda closures and hoisted functions.