Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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