What happens if i don't call dispose()?

前端 未结 4 1505
别那么骄傲
别那么骄傲 2021-01-11 17:44
    public void screenShot(string path)
    {
        var bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
                                        Scree         


        
4条回答
  •  庸人自扰
    2021-01-11 18:16

    It is mandatory to call Dispose. If you don't, there are unmanaged resources such as GDI objects that won't be cleaned up. Which means you're gonna have memory leaks.

    So yes, do call Dispose (or better, use using (...) { ... }).

提交回复
热议问题