Skip to content

Instantly share code, notes, and snippets.

@BillWagner
Created May 2, 2017 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BillWagner/d9bf14fa3ad612068eca61c6d2e1f98a to your computer and use it in GitHub Desktop.
Save BillWagner/d9bf14fa3ad612068eca61c6d2e1f98a to your computer and use it in GitHub Desktop.
local functions and lambdas and expressions, oh my
static void Main(string[] args)
{
Func<int> foo = () =>
{
int M1()
{
return 19;
}
return M1() + M2();
int M2() => 23;
};
WriteLine(foo());
}
@mstum
Copy link

mstum commented May 3, 2017

For those curious, TryRoslyn link to see what the compiler turns this into.

That's some serious effort that went into the compiler to navigate this rabbit hole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment