Should “Dispose” only be used for types containing unmanaged resources?

后端 未结 15 1616
执笔经年
执笔经年 2020-12-05 01:41

I was having a discussion with a colleague recently about the value of Dispose and types that implement IDisposable.

I think there is value

15条回答
  •  抹茶落季
    2020-12-05 02:11

    If you aggregate IDisposables then you should implement the interface in order that those members get cleaned up in a timely way. How else is myConn.Dispose() going to get called in the ADO.Net connection example you cite?

    I don't think it's correct to say that everything is an unmanaged resource in this context though. Nor do I agree with your colleague.

提交回复
热议问题