Skip to main content

Use enumerator explicitly

PropertyValue
IdRR0206
Applicable Syntaxforeach statement
Syntax Spanforeach keyword
Enabled by Default

Usage

Example #1

before.cs
foreach (var item in items)
{
yield return item;
}
after.cs
using (var en = items.GetEnumerator())
{
while (en.MoveNext())
{
yield return item;
}
}

Configuration

roslynator_refactoring.use_enumerator_explicitly.enabled = true|false