因为要多次执行Bitmap[] bmp = new Bitmap[50], 所以最好每次执行完能释放内存。用using(Bitmap[] bmp = new Bitmap[50]){}好像不行。 需要bmp[0].dispose();这样一个个释放,还是有其他办法?

解决方案 »

  1.   

    实现IDispose 接口的类可以使用这个using
    null有GC管理
      

  2.   

    using(Bitmap bmp = new Bitmap()){}这样可以的,但如果是Bitmap[] 错误Error 1 'System.Drawing.Bitmap[]': type used in a using statement must be implicitly convertible to 'System.IDisposable'
    怎么实现实现IDispose 接口的类?给个简单的例子
      

  3.   

    我最后用了List<Bitmap> bmp = new List<Bitmap>();然后在加一句 bmp.Clear();,不知道这样是不是清理了呢?