I have seen a lot of questions about whether to declare variables inside or outside a `for` loop scope. This is discussed at length, for example [here](https://stackoverflow.com/questions/7383016/reference-type-variable-recycling-is-a-new-reference-variable-created-every-lo), [here](https://stackoverflow.com/questions/6343644/does-moving-variable-declaration-outside-of-a-loop-actually-increase-performance), and [here](https://stackoverflow.com/questions/3241483/should-variable-declarations-always-be-placed-outside-of-a-loop). The answer is that there is absolutely no performance difference (same IL), but for clarity, declaring variables in the tightest scope is preferred.

I was curious about a slightly different situation:

```
int i;

for (i = 0; i < 10; i++) {
    Console.WriteLine(i);
}

for (i = 0; i < 10; i++) {
    Console.WriteLine(i);
}

```

versus

```
for (int i = 0; i < 10; i++) {
    Console.WriteLine(i);
}

for (int i = 0; i < 10; i++) {
    Console.WriteLine(i);
}

```

I expected both methods to compile to the same IL in Release mode. However, this is not the case. I'll spare you the full IL and just point out the difference. The first method has one local:

```
.locals init (
    [0] int32 i
)

```

while the second has just two locals, one for each `for` loop counter:

```
.locals init (
    [0] int32 i,
    [1] int32 i
)

```

So there is a difference between these two which is not optimized away, which is surprising to me.

**Why am I seeing this, and is there actually a performance difference between the two methods?**