Is there a reason for C#’s reuse of the variable in a foreach?
The compiler declares the variable in a way that makes it highly prone to an error that is often difficult to find and debug, while producing no perceivable benefits. Your criticism is entirely justified. I discuss this problem in detail here: Closing over the loop variable considered harmful Is there something you can do with … Read more