I have two classes A and B, B inheriting from A and additionally having a member of type List<OtherObject>.
Now I would need a reference to the List.Count property in class A reflecting changes that happen to the List in class B (removing/adding items). What’s the best way to accomplish that, without changing the int member in class A by myself?
EDIT: OK, it is a little bit more complicate and I have some simplified code here for explanation: The int member myCount should hold the reference I was talking about.
public abstract class A{
protected int myCount;
public void Process()
{
ProcessSpecificRequest();
if(myCount == 0){
//Do something
}
}
protected abstract void ProcessSpecificRequest();
}
public class B: A {
private List<Object> myList;
protected override void ProcessSpecificRequest()
{
//Do something with the List
}
}
1 Answer