In the following program, DummyMethod always print 5. But if we use the commented code instead, we get different values (i.e. 1, 2, 3, 4). Can anybody please explain why this is
I think it is because the variable i is put to the heap (it's a captured variable)
i
Take a look at this answer.