Why is it always necessary to implement IDisposable on an object that has an IDisposable member?

后端 未结 7 570
耶瑟儿~
耶瑟儿~ 2020-12-18 09:55

From what I can tell, it is an accepted rule that if you have a class A that has a member m that is IDisposable, A should implement IDisposable and it should call m.Dispose(

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-18 10:24

    Even if you don't care in this particular case, you should still follow the standard because you will care in some cases. It's much easier to set a standard and follow it always based on specific guidelines than have a standard that you sometimes disregard. This is especially true as your team grows and your product ages.

提交回复
热议问题