Yap. I realized why putting dim x=i in the loop works.

I was told a long time ago that in VB6, no matter where you put the dim statement, variables are always allocated at the beginning of the function. Not so in vb.net

That's my first question actually.

The way closure works is vb.net will make a special class and all local variables will be a member of that class. Which I think is quite an inefficient way to do so. I think a member of that closure class should change only when the delegate is created or assigned.

So my second question is the design choice. Why Microsoft decided to change the member closure class every time the local variable change? Why not just once?