Deconstruct foreach variable
Property | Value |
---|---|
Id | RR0217 |
Applicable Syntax | foreach 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