Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 891 Bytes

File metadata and controls

51 lines (37 loc) · 891 Bytes
layout page
title CC0006
tagline ForInArrayAnalyzer

|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

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

Code fix

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

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

![Code fix]({{ BASE_PATH }}/assets/images/CC0006/codefix0.png)

Related rules

None

See also

TBD