“ClosureAndForeach” (Problem)

What will the following code display?

var actions = new List<Action>();
foreach (var i in Enumerable.Range(1, 3))
  actions.Add(() => Console.WriteLine(i));
foreach (var action in actions)
  action();

Solution

Last updated