IDisposable and the using Keyword : Using : Statement C# Examples


C# Examples » Statement » Using »

 

IDisposable and the using Keyword









    
using  System;
      
public  class  MyClass  :  IDisposable
{
        public  MyClass()
        {
                Console.WriteLine("constructor");
        }
      
        ~MyClass()
        {
                Console.WriteLine("destructor");
        }
      
        public  void  Dispose()
        {
                Console.WriteLine("implementation  of  IDisposable.Dispose()");
        }
}
      
public  class  MainClass
{
        static  void  Main()
        {
                using(MyClass  MyObject  =  new  MyClass())
                {
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Using