Why does 'sealed' affect the implementation of IDisposable?

前端 未结 3 914
野趣味
野趣味 2021-01-14 02:49

After reading the answer here, I decided to mark my class as sealed in order to simplify the IDisposable implementation. Why does sealed affect the implementation of IDispo

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 03:28

    Making a class sealed means that there can be no classes derived from it. That means that the implementation of IDisposable doesn't need to take into account the behavior (or misbehavior) of derived classes.

提交回复
热议问题