C# avoid user to override internal protected methods. I know this question has been asked and I found Eric Lippert's example about it. But I didn't consider that as a good idea. Here is my example:
// A.dll
public abstract class A {
public abstract void Method1();
internal protected abstract void Method2();
}
// B.dll, ref A.dll
public class B : A {
public override void Method1();
internal protected override void Method2();
}
public class B1 {
public void MethodC(){
var b = new B();
// can access b.Method1
// can access b.Method2
}
}
// C.dll, ref A.dll and B.dll
public class C {
public void MethodC(){
var b = new B();
// can access b.Method1
// can not access b.Method2
}
}
In this case, Method2 can be accessed by B1, not by C. But since internal protected can not be override, that will be not convenient to do this. How do you guys think about it?
---- add comment ---------
My purpose is clear. I want to let Method2 can be accessed by B1, and I don't want Method2 access by C. The problem is that C# does not allow to overwrite "internal protected".
---- add comment again ---------
Well, I know what's the problem now. This question is easy but Eric Lippert's example make it complex.