public class CaptchaImage {
public Bitmap Image {
get { return this.image; }
}
private Bitmap image;
~CaptchaImage() {
Dispose(false);
}
public void Dispose() {
GC.SuppressFinalize(this);
this.Dispose(true);
}
protected virtual void Dispose(bool disposing) {
if (disposing)
// Dispose of the bitmap.
this.image.Dispose();
}
}
Is this the correct way of disposing of a Bitmap image? We are using the destructor to free the allocated memory. Is it correct or do we have any better alternatives?