Skip to main content

Deconstruct foreach variable

PropertyValue
IdRR0217
Applicable Syntaxforeach statement
Enabled by Default

Summary

type or identifier

Usage

Example #1

before.cs
var dic = new Dictionary<string, object>();

foreach (var kvp in dic)
{
var k = kvp.Key;
var v = kvp.Value.ToString();
}
after.cs
var dic = new Dictionary<string, object>();

foreach (var (key, value) in dic)
{
var k = key;
var v = value.ToString();
}

Configuration

roslynator_refactoring.deconstruct_foreach_variable.enabled = true|false