I have two projects in one solution and I added a dependency of assembly A
in the assembly B
So here I have the asembly A where I have the folloing class
public class Person {
protected virtual void CalculatePay() {
Console.WriteLine("CalculatePay in Person class.");
}
protected internal virtual void test11() {
Console.WriteLine("test11 in Person class.");
}
}
then I have the assembly B where I have the following class
class uno : Person {
protected override void CalculatePay() {
Console.WriteLine("CalculatePay in uno class.");
}
protected internal override void test11() { //CS0507
Console.WriteLine("test11 in uno class.");
}
}
So I am able to override the protected method CalculatePay()
just fine but when I try to override the protected internal method test11()
I get the exception saying I can not change the access modifier of an overridden method but I am clearly not channging it.
The error goes away if I change the modifier of test11()
from protected internal to protected in the class uno
which is weird to me.
This happens only when I override in a different assembly. It does not happen when I override in the same assembly.
I think I am missing something here. Can you please tell me exactly why this happnes?