Declare IDisposable for the class or interface?

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

    Personally, if all ISample's should be disposable I'd put it on the interface, if only some are I'd only put it on the classes where it should be.

    Sounds like you have the latter case.

提交回复
热议问题