Skip to content

Instantly share code, notes, and snippets.

@binki
Created March 14, 2017 17:14
Show Gist options
  • Save binki/e448076d5256d31dc14c484bac40facf to your computer and use it in GitHub Desktop.
Save binki/e448076d5256d31dc14c484bac40facf to your computer and use it in GitHub Desktop.
Local function can capture like normal
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