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 seem to have settled on returning IEnumerable with the objects cloned.
public IEnumerable GetFooseList() {
foreach(var foos in Collection) {
yield return foos.Clone();
}
}
This allows no changes in the collection. Remember that ReadonlyCollection is "leaky" since the objects inside it can be changed as mentioned in a link in another post.