Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created June 19, 2013 02:31
Show Gist options
  • Save Fhernd/5811265 to your computer and use it in GitHub Desktop.
Save Fhernd/5811265 to your computer and use it in GitHub Desktop.
Uso del método estátido Collect de System.GC.
class A
{
~A()
{
Console.WriteLine("Destruye instancia de A");
}
}
class B
{
object Ref;
public B(object o)
{
Ref = o;
}
~B()
{
Console.WriteLine("Destruye instancia de B");
}
}
class PruebaColeccionadorBasura
{
static void Main()
{
B b = new B(new A());
b = null;
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment