using System.Collections.Generic;
public static void Main()
public static void SimpleClosures()
Func<int, int> getOlderOn = x => age + x;
Console.WriteLine(getOlderOn(12));
public static void ChangedVariable()
int nonLocalVariable = 1;
return localVariable + nonLocalVariable;
Console.WriteLine(result);
public static void Copy()
List<Func<int>> functions = new List<Func<int>>(3);
for (int nonLocalVariable = 0; nonLocalVariable < 3; nonLocalVariable++)
Func<int> function = () => nonLocalVariable;
foreach (Func<int> function in functions)
private static Func<int> longLifeFunction;
public static void LongLived()
byte[] shortLifeVariable = new byte[5000000];
byte value = shortLifeVariable[0];