Forced garbage collection : GC : Development C# Examples


C# Examples » Development » GC »

 

Forced garbage collection









    
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();
    }
}
    
   
  
   



Output

Created Junk
Destroyed Junk


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» GC