C#: Dispose() a Bitmap object after call Bitmap.save()?
问题 I have this: Bitmap bmp = new Bitmap(image); //image processing bmp.Save(path + fileName); and I want to know if I need to call bmp.Dispose() after this code. Thanks in advance. 回答1: I would use using block and Path.Combine using(var bmp = new Bitmap(image)) { // image processing bmp.Save(Path.Combine(path ,fileName)); } 回答2: Yes. Better yet, you could wrap your bmp in a using block, this will take care of the disposal for you using(var bmp = new Bitmap(image)) { bmp.Save(...); } Save's sole