I have 3 classes:
I wonder how do I hide a method at BaseClass to not appear in ClientClass?
Example:
public class BaseClass
{
public void BaseMethod1()
{
}
public void BaseMethod2()
{
}
}
public class MiddleClass : BaseClass
{
public void MiddleMethod()
{
this.BaseMethod1();
}
}
public class ClientClass : MiddleClass
{
public void Test()
{
this.MiddleMethod();
this.BaseMethod1(); // I can't see this method here
}
}
Edit: I modified my sample, I put "this.BaseMethod1();" in MiddleClasse
You need to define that method as private. Just for reference, here you have more information about access modifiers
public: The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private: The type or member can be accessed only by code in the same class or struct.
protected: The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
internal: The type or member can be accessed by any code in the same assembly, but not from another assembly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With