use*_*334 5 .net c# mono protected internal
protected internal class foo
{
//this compiles without any errors
}
Run Code Online (Sandbox Code Playgroud)
也
internal class bar
{
public int quix;
protected internal int zyx;
//this compiles without any errors
}
Run Code Online (Sandbox Code Playgroud)
是这些编译器错误还是我对标准的误解?
说明:
编辑:我使用Mono的事实是不必要的,因为问题是关于标准说什么而不是MONO做什么或不做什么.也许我正在编写自己的编译器.这就是为什么我引用MSDN准确地说是允许什么和不允许什么.
mat*_*mmo 22
正如我在评论上面提到的,protected internal意味着protected 或 internal 不 protected 和 internal.这里没有错误:)
有关进一步的信息/解释是haacked
回答你的问题:
命名空间(而不是另一个类)中的类只能声明为public或internal.无论其,在另一个类中的一类可以声明为protected internal,private等等.
是的,protected internal可以在访问修饰符比其成员更严格的类中使用,请参阅下面的完全有效用法的示例(请注意该类在Program类中):
public class Program
{
static void Main(string[] args)
{
}
private class Foo
{
private int priv { get; set; }
protected internal int protint { get; set; }
public int pub { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)