title: Scope and how to narrow it using VB.Net
body: <p>If I want to narrow scope of a variable in C#, I can introduce additional braces - i.e.:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          myClass x = new myClass();
          x.MyProperty = 1000;
          Console.WriteLine("x = " + x.MyProperty);
  
          {
              myClass y = new myClass();
              y.MyProperty = 2000;
              Console.WriteLine("y = " + y.MyProperty);
          }
  
          myClass y2 = new myClass();
          y2.MyProperty = 3000;
          Console.WriteLine("y2 = " + y2.MyProperty);
  
      }
  
      class myClass
      {
  
          public int MyProperty { get; set; }
  
      }
  }
  </code></pre>
  
  <p>In the ide, I can no longer reference y outside of the scope introduced by the new braces. I would have thought that this would mean that the variable y would be available for garbage collection. </p>
  
  <p>(it is interesting to note that when viewing the compiled code using reflector it appears that there is no difference with or without the additional braces)</p>
  
  <p>Is there any way similar to this to narrow scope when using VB.net? Does this have any impact on when variables defined in the inner scope may be garbage collected?</p>