-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Loops, Lambdas, and Variables #16073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In your first block of code you have this line
which seems to reference an array |
try this. you would need to use local variable for it to work
|
@felyperennan That was a typo when copying and pasting into the issue. |
I opened a similar one aspnet/Blazor#665 |
This is a general C# question about how loops and lambda hoisting interact. The answer is that |
This might be a known Razor issue, and since I haven't used Razor in ages I was caught off guard.
This does not work:
You get an exception with the h5 line (the previous lines are fine):
The work around is to add a capture variable in the loop like so:
Like I said not sure if this is fixable since it might be in Razor like that, but at the very least a better error message and adding this to the docs would be helpful.
The text was updated successfully, but these errors were encountered: