ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Code Inspection: Loop control variable is never changed inside loop

Last modified: 05 December 2022

This inspection reports loops that are not constrained — they either fail immediately or run indefinitely. In the following code snippet

the loop variable condition is not varying, which causes the loop to execute indefinitely (unless for instance an exception occurs). In this synthetic example the problem is obvious, but if there is a lot of code inside the loop, you might never notice that until the program hangs at runtime.