I'm assuming you mean like this:dpratt71 said:W3bbo said:*snip*I am at least somewhat acquainted with ReadOnlyCollection. In any case, I consider ReadOnlyCollection vs. IEnumerable as mostly apples vs. oranges. Changing nothing else about your example, what would be the drawback to defining TheCollection as type IEnumerable<Object>?
class Foo {
public IEnumerable<Object> TheCollection { get; private set; }
private List<Object> underlyingCollection;
public Foo() {
underlyingCollection = new List<Object>();
TheCollection = (IEnumerable<Object>) underlyingCollection;
}
}