Vannevelj / VSDiagnostics

A collection of static analyzers based on Roslyn that integrate with VS
GNU General Public License v2.0
65 stars 16 forks source link

Inline out variable #627

Open Hosch250 opened 7 years ago

Hosch250 commented 7 years ago

This is a common-ish pattern:

MyType foo;
if (MyType.TryParse("string", out foo)) { /* use foo */ }

We can now write this as:

if (MyType.TryParse("string", out MyType foo)) { /* use foo */ }

foo is accessible in the same scope in both statements.