All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.csharp.rules.csharpsquid.S127.html Maven / Gradle / Ivy

There is a newer version: 4.0
Show newest version

Loop counters should not be modified in the body of the loop to prevent unexpected side effects.

Noncompliant Code Example

class Foo
{
    static void Main()
    {
        for (int i = 1; i <= 5; i++)
        {
            Console.WriteLine(i);
            if (condition)
            {
               i = 20;
           }
        }
    }
}

Compliant Solution

class Foo
{
    static void Main()
    {
        for (int i = 1; i <= 5; i++)
        {
            Console.WriteLine(i);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy