title: Memory management for a class
body: <p>in the following code, How - in terms of memory management - is <code>class A</code> allocated and deallocated in .NET (C#). </p>
  
  <pre><code>class A
  {
      public static m1(int x, int y)
      {
          int x, y;
          return x+y;
      }
      int m2(int p, int q)
      { 
          int p, int q;
          return p+q;
      }
      int x=10; 
      int y;
      const int x=10;
      readOnly y=20;
  
      public int x
      {
          get {y}
          set {y=value}
      }
  }
  
  class B
  {
      A a=new A();  // what happens when initializing class A;
  }
  </code></pre>
  
  <p>Note: that the usage of <code>class B</code> could be either the entry point of the program, or an object instance, but the scope here is on memory management and allocation of the instance of <code>class A</code>.</p>