All rules
IDE0063Code block preferences MS default: Suggestion
Use simple using statement
Prefer the declaration-form `using` statement over a `using` block.
Microsoft docsDescription
Prefers using var x = ...; over the older using (var x = ...) { } block form when scoping to the end of the enclosing block is acceptable.
Why it matters
The simple form reduces nesting and visual noise for the common disposal pattern.
Examples
Avoid
using (var stream = File.OpenRead(path))
{
Process(stream);
} Prefer
using var stream = File.OpenRead(path);
Process(stream);Configurable options
Vote for the value each option should take in the generated .editorconfig.
csharp_prefer_simple_using_statement default:
trueYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0