Scope modifiers: Difference between revisions
Content deleted Content added
m C# minor edit |
C# made table clearer |
||
Line 300: | Line 300: | ||
protected internal //visible to anything inside the same assembly and also to derived classes outside the assembly. |
protected internal //visible to anything inside the same assembly and also to derived classes outside the assembly. |
||
private //visible only to the current class. |
private //visible only to the current class. |
||
C# 7.2 adds: |
//C# 7.2 adds: |
||
private protected //visible to current class and to derived classes inside the same assembly. |
private protected //visible to current class and to derived classes inside the same assembly. |
||
// |
// | | subclass | other class || subclass | other class |
||
//Modifier | class | in same assembly | in same assembly || outside assembly | outside assembly |
|||
//-------------------------------------------------------- |
//------------------------------------------------------------------------------------------------------- |
||
⚫ | |||
// |
//public | Yes | Yes | Yes || Yes | Yes |
||
//protected |
//protected internal | Yes | Yes | Yes || Yes | No |
||
// |
//protected | Yes | Yes | No || Yes | No |
||
// |
//internal | Yes | Yes | Yes || No | No |
||
⚫ | |||
// C# 7.2: |
// C# 7.2: |
||
//private protected | |
//private protected | Yes | Yes | No || No | No</lang> |
||
If no modifier is specified, it defaults to the most restrictive one.<br/> |
If no modifier is specified, it defaults to the most restrictive one.<br/> |
||
In case of top-level classes/structs/interfaces/enums this means internal, otherwise it means private. |
In case of top-level classes/structs/interfaces/enums this means internal, otherwise it means private. |