using System; using System.Collections.Generic; public class Test { public static void Main() { int[] items = {1, 2, 3, 4, 5}; List actions = new List(); foreach(int i in items) { int j = i; // Reassignment because of how foreach works, but this // is still part of block scope; it's not a closure. actions.Add(() => Console.WriteLine(j.ToString())); } foreach(Action a in actions) a(); } }