Declare IDisposable for the class or interface?

后端 未结 7 2132
心在旅途
心在旅途 2020-12-29 01:00

Starting from the follwing situation:

public interface ISample
{
}

public class SampleA : ISample
{
   // has some (unmanaged) resources that needs to be di         


        
相关标签:
7条回答
  • 2020-12-29 01:52

    IDispoable being a very common interface, there's no harm having your interface inheriting from it. You will so avoid type checking in your code at the only cost to have a no-op implementation in some of your ISample implementations. So your 2nd choice might be better from this point of view.

    0 讨论(0)
提交回复
热议问题