Practice ยท 2 of 2
Debug: Every Button Fires Three Times
CHALLENGE
Difficulty: intermediate+25 XP
Classic bug: a loop registers three "print i" lambdas, but pressing any single button prints 3 โ the last value. Build below reproduces it. Fix Build so each lambda remembers its OWN index, and keep Sum as is (it is correct).
``csharp
static List<Func<int>> Build(int n); // lambda i returns i
static int Sum(List<Func<int>> fs); // invoke all, total
``
Press Submit to check your solution.
Back to lesson: Practice: Closure Capture Practice