Finalizers with Dispose() in C#

前端 未结 2 2020
情歌与酒
情歌与酒 2021-01-06 03:45

See the code sample from MSDN: (http://msdn.microsoft.com/en-us/library/b1yfkh5e(v=VS.100).aspx)

// Design pattern for a base class.
public class Base: IDisp         


        
2条回答
  •  甜味超标
    2021-01-06 04:20

    If someone forgets to call Dispose, the finalizer will (eventually) run to do final cleanup. Since finalization hurts performance, ideally no-one will forget to Dispose. The using construct helps a little with that.

提交回复
热议问题