Declare IDisposable for the class or interface?

后端 未结 7 2219
心在旅途
心在旅途 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:49

    If you apply the using(){} pattern to all your interfaces it's best to have ISample derive from IDisposable because the rule of thumb when designing interfaces is to favor "ease-of-use" over "ease-of-implementation".

提交回复
热议问题