I have the following classes:
public class Essentials
{
public void DoSomething()
{
//doing base stuff...
}
}
public class NetworkEssentials : Essentials
{
public void DoNetworkSomething()
{
//doing something
}
}
public class someClass : NetworkEssentials
{
public void DoSomeSomething()
{
base.DoSomething(); //The thing I would like to prevent, as to block this from happening.
//attention: i dont want to change methods names so it will call the first parent, i still want to maintain a different method names to each class type
}
}
I want to prevent someClass
from being able to invoke methods in its parent's parent, only allowing direct inherit classes to invoke its base methods.
Is there anyway to do it?
Additional explanation:
basically, i have some mandatory fields i require that each object have, but there are some objects, not all, i demand to have an extra mandatory field. lets call them 1 2 3 , whereas 1 is the top parent. i want class 3 to call a class 2 method and this class 2 method will call the class 1 method, because only class 2 have this "extra" field. class 1 cant handle with this field because it doesnt recognize it at all