Skip to content

Instantly share code, notes, and snippets.

@JimBobSquarePants
Created June 21, 2017 14:20
Show Gist options
  • Save JimBobSquarePants/1d6d10afe4b288f51f792f1c97763e2d to your computer and use it in GitHub Desktop.
Save JimBobSquarePants/1d6d10afe4b288f51f792f1c97763e2d to your computer and use it in GitHub Desktop.
Demoing local assignment of local functions
void Main()
{
string m;
void DoSomething(int i)
{
m = "DoSomething";
m.Dump();
(i + 1).Dump();
}
void DoSomethingElse(int i)
{
m = "DoSomethingElse";
m.Dump();
(i - 1).Dump();
}
Action<int> action;
Random r = new Random();
if (r.Next(1, 4) > 2)
{
action = DoSomething;
}
else
{
action = DoSomethingElse;
}
action(99);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment