using System; class Junk { public Junk() { Console.WriteLine("Created Junk"); } ~Junk() { Console.WriteLine("Destroyed Junk"); } } class MainClass { public static void Main() { Junk j = new Junk(); j = null; GC.Collect(); } }
Created Junk Destroyed Junk