How to hide some members of an interface

前端 未结 7 2205
甜味超标
甜味超标 2020-12-03 11:42

I would like to create a custom collection that implements ICollection.

But I would like not to expose some memebers of ICollection like

7条回答
  •  無奈伤痛
    2020-12-03 12:26

    What makes you so sure that you really need to implement ICollection? If you don't want some methods from this interface, don't use it, declare a new interface with methods that you want. The whole point of using ICollection is to make other objects think that they can do with your object whatever they can do with any other collection.

提交回复
热议问题