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
I typically return an IEnumerable<T>
.
Once you make a collection readonly (so methods like Add
, Remove
and Clear
no longer work) there's not much left that a collection supports that an enumerable doesn't - just Count
and Contains
, I believe.
If consumers of your class really need to treat elements like they're in a collection, it's easy enough to pass an IEnumerable
to List<T>
's constructor.