I was digging around on twitter and I found a great comment from @BenAtExocortex:
On the “i++” line, the C# compiler (or Resharper / Telerik JustCode / etc) would throw a compiler error or warning, telling you that the variable isn’t defined at this point. This happens because the variable declaration is scoped to the if statement.
The “i” var in the “doSomething” function is assigned the value returned by the immediate function. The “x” var is scoped to the immediate function giving us block-like scope for our variables.