local variable scope in linq anonymous method ( closure)
问题 What is the scope of local variable declared in Linq Query. I was writing following code static void Evaluate() { var listNumbers = Enumerable.Range(1, 10).Select(i => i); int i = 10; } Compiler flagged error on line int i=10, stating A local variable named 'i' cannot be declared in this scope because it would give a different meaning to 'i', which is already used in a 'child' scope to denote something else I am unable to understand why this error is coming. My understanding was that i will