Last active
August 29, 2015 14:01
-
-
Save controlflow/11d6360ea827164aaa1e to your computer and use it in GitHub Desktop.
C# 6.0 declaration expressions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CA "To declaration statement" | |
{ | |
var t = F(out var x); | |
// => | |
int x; | |
var t = F(out x); | |
} | |
// Inspection "Declaration expression is not used" + QF "Remove variable" | |
{ | |
var t = F(var x = smth); | |
// => | |
var t = F(smth); | |
} | |
// Inspection "Use var" for declaration expressions | |
{ | |
d.F(out string t); | |
F(string t = "abc"); | |
// => | |
d.F(out var t); | |
F("abc"); | |
} | |
// Inspection "Move declaration closer to usage" | |
{ | |
string t; | |
d.F(out t); | |
// => | |
d.F(out var t) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment