Created
March 14, 2017 17:14
-
-
Save binki/e448076d5256d31dc14c484bac40facf to your computer and use it in GitHub Desktop.
Local function can capture like normal
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
using System; | |
namespace LocalFuncCreatesClass | |
{ | |
class Program | |
{ | |
static Func<int> GetNextThing { get; set; } | |
static void Main(string[] args) | |
{ | |
var current = 2; | |
int next() => ++current; | |
GetNextThing = next; | |
Console.WriteLine(next()); | |
Console.WriteLine(GetNextThing()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment