Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. class A
  2. {
  3.     ~A()
  4.     {
  5.         Console.WriteLine("Destruye instancia de A");
  6.     }
  7. }
  8.  
  9. class B
  10. {
  11.     object Ref;
  12.  
  13.     public B(object o)
  14.     {
  15.         Ref = o;
  16.     }
  17.  
  18.     ~B()
  19.     {
  20.         Console.WriteLine("Destruye instancia de B");
  21.     }
  22. }
  23.  
  24. class PruebaColeccionadorBasura
  25. {
  26.     static void Main()
  27.     {
  28.         B b = new B(new A());
  29.         b = null;
  30.  
  31.         GC.Collect();
  32.         GC.WaitForPendingFinalizers();
  33.     }
  34. }