Sco*_*ith 8 c# protected internal
我有一个接口和一个在同一个程序集中定义的抽象基类:
IFoo.cs:
internal interface IFoo { ... }
Run Code Online (Sandbox Code Playgroud)
Base.cs:
public abstract class Base
{
internal protected Base(IFoo foo) { ... }
}
Run Code Online (Sandbox Code Playgroud)
这会生成以下编译器错误:
CS0051: Inconsistent accessibility: parameter type 'IFoo' is less
accessible than method 'Base.Base(IFoo)'
Run Code Online (Sandbox Code Playgroud)
如果我将Base类构造函数设置为仅内部,则错误消失.由于该类是抽象的,可能在可访问性中添加受保护并不能完成任何事情......
不过,我不明白这个错误.MSDN将'protected internal'定义为
"访问仅限于当前程序集或从包含类派生的类型"
内部接口IFoo如何比内部受保护的构造函数更难访问?