title: garbage collection after a local method in C#
body: <p>I'm a beginner in C#, just a question on garbage collection in C#. Let's say we have the following code:</p>
  
  <pre><code>...
  public void Test()
  {
     ...
     MyClass a = new Myclass()
  }
  </code></pre>
  
  <p>so when will a be garbage collected by CLR? I mean immediately garbage collected after Test() method gets executed? or when the program finishes?</p>