protected internal class foo
{
    //this compiles without any errors
}
also
internal class bar
{
    public int quix;
    protected internal int zyx;
    //this compiles without any errors
}
Are these compiler bugs or my misinterpretation of the standard?
Explanation:
Edit: The fact that I'm using Mono is unnecessary cause the question was about what standard says and not what MONO does or does not. Maybe I'm coding my own compiler. That's why I quoted MSDN to be precise what is allowed and what is not.
protected internal: The type or member can be accessed by any code in the assembly in which it's declared, or from within a derived class in another assembly. private protected: The type or member can be accessed by types derived from the class that are declared within its containing assembly.
The private protected keyword combination is a member access modifier. A private protected member is accessible by types derived from the containing class, but only within its containing assembly. For a comparison of private protected with the other access modifiers, see Accessibility Levels.
public is visible from wherever. internal is visible only within an assembly. You can then put a lot of sophistication on a method, but "protect" it using facade methods that may help the programmer to call the method correctly.
Default access modifiers at Namespace level are internal. Default access modifiers at Class level are private.
As mentioned in my comment above, protected internal means protected or internal NOT protected and internal. No bug here :)
Further information/explanation is on haacked
In response to your questions:
A class within a namespace (and not within another class) can only be declared as public or internal. HOWEVER, a class within another class can be declared as protected internal, private, etc.
Yes, protected internal can be used inside a class whose access modifier is more strict than it's members, see example of a perfectly valid usage below (note that the class is inside the Program class):
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; }
    }
}
From Access Modifiers (C# Programming Guide)
protected internal
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in 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