Search code examples
roslynroslyn-code-analysis

C# CodeAnalysis ProtectedAndInternal vs ProtectedOrInternal


I'm unclear about the distinction between the Accessibility values ProtectedAndInternal and ProtectedOrInternal.

I found a reference stating ProtectedOrInternal maps to the source code construct protected internal.

But -- assuming that's correct -- what does it mean for something to be both protected and internal?


Solution

  • ProtectedOrInternal corresponds to protected internal:

    The protected internal keyword combination is a member access modifier. A protected internal member is accessible from the current assembly or from types that are derived from the containing class. For a comparison of protected internal with the other access modifiers, see Accessibility Levels.

    ProtectedAndInternal corresponds to private protected:

    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.