I\'m looking for some way to effectively hide inherited members. I have a library of classes which inherit from common base classes. Some of the more recent descendant clas
You can use an interface
public static void Main()
{
NoRemoveList testList = ListFactory.NewList();
testList.Add(" this is ok ");
// not ok
//testList.RemoveAt(0);
}
public interface NoRemoveList
{
T this[int index] { get; }
int Count { get; }
void Add(T item);
}
public class ListFactory
{
private class HiddenList: List, NoRemoveList
{
// no access outside
}
public static NoRemoveList NewList()
{
return new HiddenList();
}
}