Skip to content

Instantly share code, notes, and snippets.

@controlflow
Last active August 29, 2015 14:01
Show Gist options
  • Save controlflow/11d6360ea827164aaa1e to your computer and use it in GitHub Desktop.
Save controlflow/11d6360ea827164aaa1e to your computer and use it in GitHub Desktop.
C# 6.0 declaration expressions
// 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