Best practice: How to expose a read-only ICollection

前端 未结 7 1757
礼貌的吻别
礼貌的吻别 2020-12-16 02:39

I have an ICollection called foos in my class which I want to expose as read-only (see this question). I see that the interface defines a

7条回答
  •  被撕碎了的回忆
    2020-12-16 03:00

    Sometimes you may want to use an interface, perhaps because you want to mock the collection during unit testing. Please see my blog entry for adding your own interface to ReadonlyCollection by using an adapter.

提交回复
热议问题