Fork me on GitHub
TypeName ForInArrayAnalyzer
Check Id CC0006
Category Style
Severity Info

Cause

A simple iteration using a for loop and it is not interacting with the indexer anywhere but in a single place where it accesses the array used in the for condition to assign it to a variable, which is itself used isnde the for loop.

Example

var array = new [] { 1, 2, 3 };
for (int i = 0; i < array.Length; i++)
{
    var someNumber = array[i];
    //some code
}

Code fix

A code fix will be presented to you that will transform the code:

var array = new [] { 1, 2, 3 };
foreach (var someNumber in array)
{
    //some code
}

Code fix

Related rules

None

See also

TBD