Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com
I've noticed in my LINQ code Resharper Warning "'Access to modified closure'". The search pointed that there is very confusing potential error.
If  for/foreach loop variable is used only in Linq methods (more general, only as a parameter for delegates) , only the last value of the variable will be used for all calls.
It always required to create local variable inside loop and use the local variable instead of loop variable.
 
Posted on Saturday, July 18, 2009 7:47 AM .Net Framework , LINQ | Back to top


Comments on this post: Declare local variable within the loop instead of using loop variable in Linq methods

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net