title: c# garbage collection not work .netframework 4 and above
body: <p>this code works fine with netfarmework 3.5 but when i change the version to netframework 4 and 4.5 garbage collector not collect the object and destructor nut runs </p>
  
  <pre><code>  static void Main(string[] args)
      {
          Console.WriteLine("count=" + Employee.count);
          Employee e1 = new Employee("test", "test");
          e1 = null;
          //force garbage collection
          GC.Collect();
          //wait until collection complete
          GC.WaitForPendingFinalizers();
          Console.WriteLine("after GC count= " + Employee.count);
          Console.ReadKey();
      }
  </code></pre>
  
  <p>and this is class</p>
  
  <pre><code>class Employee
  {
      public static int count;
      public string firstName;
      public string lastName;
      //constructor
      public Employee(string fname, string lname)
      {
          firstName = fname;
          lastName = lname;
          ++count;
          Console.WriteLine("constructor count= "+count);
      }
      //destructor
      ~Employee()
      {
  
          --count;
          Console.WriteLine("destructor count= " + count);
      }
  
  
  }
  </code></pre>