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

前端 未结 4 1492
别那么骄傲
别那么骄傲 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

    The "Dispose" method comes from the "IDisposable" interface and does the following:

    Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

    Basically you can say that the resources used are not released immediately . Not even when they are no longer needed. But only when the garbage collector releases them.

    For more information check out the MSDN: IDisposable Interface

    Other useful links on this topic:

    • Garbage Collection
    • using Statement (C# Reference)

提交回复
热议问题