C#class的Dispose和Finalize模板

   class Test : IDisposable
   {
     private bool isDisposed = false;
   
     ~Test()
     {
       Dispose(false);
     }
   
     protected void Dispose(bool disposing)
     {
       if (disposing)
       {
         // Code to dispose the managed resources of the class
       }
       // Code to dispose the un-managed resources of the class
   
       isDisposed = true;
     }
   
     public void Dispose()
     {
       Dispose(true);
       GC.SuppressFinalize(this);
     }
   }
posted @ 2010-06-14 21:55  与时俱进  阅读(325)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈