C# 代码分析 ProtectedAndInternal 与 ProtectedOrInternal

C# CodeAnalysis ProtectedAndInternal vs ProtectedOrInternal

我不清楚 AccessibilityProtectedAndInternalProtectedOrInternal 之间的区别。

我找到了一个引用,说明 ProtectedOrInternal 映射到源代码构造 protected internal

但是——假设这是正确的——同时保护内部的东西意味着什么?

它是两种辅助功能级别的组合。某些对象是否可以从同一程序集(内部)访问或可以使用派生类型(受保护)。它们不一样,但可以互换使用

ProtectedOrInternal对应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对应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.