title: Explicit Local Scopes - Any True Benefit?
body: <p>I was cleaning up some code and removed an <code>if</code> statement that was no longer necessary. However, I realized I forgot to remove the brackets. This of course is valid and just created a new local scope. Now this got me thinking. In all my years of C# development, I have never come across a reason to use them. In fact, I kind of forgot I could do it. </p>
  
  <p>Is there any actual benefit to defining a local scope? I understand I can define variables in one scope and then define the same ones again in an unrelated scope (for, foreach, etc.) like below:</p>
  
  <pre><code>void SomeMethod()
  {    
      {
          int i = 20;
      }
  
      int i = 50; //Invalid due to i already being used above.
  }
  
  void SomeMethod2()
  {    
      {
          int i = 20;
      }
      {
          int i = 50; //Valid due to scopes being unrelated.
      }
      {
          string i = "ABCDEF";
      }
  }
  </code></pre>
  
  <p>What's the true point of defining a local scope? Can there actually be any sort of performance gain (or potentially a loss)? I know you could do this in C++ and was part of helping you manage memory, but because this is .NET, would there really be a benefit? Is this just a bi-product of the language that let's us define random scopes even though there is no true benefit? </p>