Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created September 28, 2017 11:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
using System;
namespace ClosureExample
{
class Program
{
static void Main(string[] args)
{
Action counterIncrementAction = CounterIncrementAction();
counterIncrementAction();
counterIncrementAction();
Console.ReadLine();
}
static Action CounterIncrementAction()
{
int counter = 0;
return delegate
{
counter++;
Console.WriteLine("Counter value is {0}", counter);
};
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment