Total .NET Analyzer Rule Documentation |
|
Review empty ForEach statements.
Remarks
For Each statements execute a statement or group of statements one time for each element in an array or collection. By having no code in a For Each statement, you are not executing any code in the loop.
For instance, the following code has an empty For statement:
' VB
For Each myItem In myCollection
Next
//C#
foreach (int item in myCollection)
{
}
In general, empty For Each statements do not serve a purpose, and should be removed.
Resolution
Review empty For Each statements to determine whether they represent undone work, contain commented code that should be enabled, or do nothing and should be removed.
See Also
For Each Statements (VB)
For Each Statements (C#)