I am trying to write an abstract base class for read-only collections that implement IList. Such a base class must implement set-indexer in order to throw away NotSupportedException, but leave get-indexer abstract. Does C # provide such a situation? Here is what I still have:
public abstract class ReadOnlyList : IList {
public bool IsReadOnly { get { return true; } }
public object this[int index] {
get {
throw new NotImplementedException();
}
set {
throw new NotSupportedException("The collection is read-only.");
}
}
}
Ideally ReadOnlyList, the installer will be able to implement, but will leave an abstract formula. Is there any syntax that allows this?
source
share