You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you believe you have an issue that affects the security of the platform please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.
Describe the bug
A clear and concise description of what the bug is. @for (var i = 1; i < int_amount_of_pages + 1; i++) { var intpagenr = i; <li class="page-item"><a class="page-link" value="@i" onclick="@(() => SetPageNR( intpagenr.ToString()))"> @i.ToString()</a></li> }
If 'int_amount_of_pages ' is 5, 'i' will always be 6 when given as an argument to 'SetPageNR', Only when you declare a local variable, equate it to 'i' and then give that as an argument is the expected behavior executed.
To Reproduce
Steps to reproduce the behavior:
Using this version of ASP.NET Core '...'
3.0 preview-5
Run this code '....'
see above
With these arguments '....'
see above
See error
unexpected behavior
Expected behavior
A clear and concise description of what you expected to happen.
i is not the max i was + 1, i is what it was when it went through that loop.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Include the output of dotnet --info
The text was updated successfully, but these errors were encountered:
The necessity to declare a variable inside your loop is just how C# lambdas work - they bind to a variable, not to the value that was in the variable when the lambda was constructed.
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.
If you believe you have an issue that affects the security of the platform please do NOT create an issue and instead email your issue details to [email protected]. Your report may be eligible for our bug bounty but ONLY if it is reported through email.
Describe the bug
A clear and concise description of what the bug is.
@for (var i = 1; i < int_amount_of_pages + 1; i++) { var intpagenr = i; <li class="page-item"><a class="page-link" value="@i" onclick="@(() => SetPageNR( intpagenr.ToString()))"> @i.ToString()</a></li> }
If 'int_amount_of_pages ' is 5, 'i' will always be 6 when given as an argument to 'SetPageNR', Only when you declare a local variable, equate it to 'i' and then give that as an argument is the expected behavior executed.
To Reproduce
Steps to reproduce the behavior:
3.0 preview-5
see above
see above
unexpected behavior
Expected behavior
A clear and concise description of what you expected to happen.
i is not the max i was + 1, i is what it was when it went through that loop.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Include the output of
dotnet --info
The text was updated successfully, but these errors were encountered: