> For the complete documentation index, see [llms.txt](https://andreyakinshin.gitbook.io/problembookdotnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://andreyakinshin.gitbook.io/problembookdotnet/en/linq/closureandfor-p.md).

# “ClosureAndFor” (Problem)

What will the following code display?

```csharp
var actions = new List<Action>();
for (int i = 0; i < 3; i++)
  actions.Add(() => Console.WriteLine(i));
foreach (var action in actions)
  action();
```

[Solution](/problembookdotnet/en/linq/closureandfor-s.md)
