dpratt71 said:
*snip*
I'm assuming you mean like this:
class Foo {
public IEnumerable<Object> TheCollection { get; private set; }
private List<Object> underlyingCollection;
public Foo() {
underlyingCollection = new List<Object>();
TheCollection = (IEnumerable<Object>) underlyingCollection;
}
}
In this case, your collection isn't actually read-only. A user of your library can cast TheCollection back to List<Object> and modify the contents of the list, which is bad in most situations (since you're
directly accessing a private data member).