using in the function

     Class aa

     {

          public aa()

          public void kk()

          {

           }

     }

     class D : IDisposable
    {
        void IDisposable.Dispose() { }
        public void Dispose() { }
        public static void Main()
        {
            using (D d = new D()) { }   // D must be Disposable, after this, "d" disappear
            aa ttt = new aa();
        }
    }

 

------------------------------------------

Dispose some types in a class, after using

 

 

using System;
public class C<T>

public class C<T> where T : IDisposable
{
   public void F(T t)
   {
      using (t) {}   

   }
}

posted @ 2010-04-20 23:39  greencolor  阅读(102)  评论(0编辑  收藏  举报