Created
June 21, 2017 14:20
-
-
Save JimBobSquarePants/1d6d10afe4b288f51f792f1c97763e2d to your computer and use it in GitHub Desktop.
Demoing local assignment of local functions
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
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