Is there any benefit to implementing IDisposable on classes which do not have resources?

后端 未结 11 2111
挽巷
挽巷 2020-12-14 05:14

In C#, if a class, such as a manager class, does not have resources, is there any benefit to having it : IDisposable?

Simple example:

pu         


        
11条回答
  •  余生分开走
    2020-12-14 05:54

    No, there will be no benefit if you don't do something useful like releasing unmanaged resources that your class might hold in the Dispose method.

提交回复
热议问题