Development resources, articles, tutorials, code samples, tools and downloads for AWS Amazon Web Services, Redshift, AWS Lambda Functions, S3 Buckets, VPC, EC2, IAM
Using the iteration variable in a lambda expression may have unexpected results.
While working on an ASP.NET project, I had faced with the warning message of Microsoft Visual Studio 2008 within a code I had built using FOR LOOP.
Using the iteration variable in a lambda expression may have unexpected results. Instead, create a local variable within the loop and assign it the value of iteration variable.
Here is the original VB.NET code block which is causing the warning message :
Solution :
And below the corrected VB.NET code which eliminates the possible error caused by using the iteration variable in a lambda expression.
You can easily notice that I added a new variable (ii) as the warning message suggests.
Within the loop the initial value of the new variable is equals to the iteration value.
Then within the VB.NET For Loop code I replaced the iteration parameter with the new variable.