Access Modifiers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

Can anyone provide advice/links on somewhere to get a definitive explanation with Examples of how "protected internal" differs from "protected", "internal" and the other access modifiers

For "protected internal" some places appear to say it means a union of protected AND internal, other places say it's protected OR internal

Thanks

Pet
 
Both the C# Reference and the C# Specification state OR.
The following is an excerpt from the Common Type System, which defines the
rules the IL/Metadata must abide by under the managed environment:

The accessibility domain of a nested member M declared in a type T within a
program P is defined as follows (noting that M might itself be a type):
a.. If the declared accessibility of M is protected internal, the
accessibility domain of M is the intersection of the accessibility domain of
T with the program text of P and the program text of any type derived from T
declared outside P.
-Rob Teixeira [MVP]

Pete said:
Hello,

Can anyone provide advice/links on somewhere to get a definitive
explanation with Examples of how "protected internal" differs from
"protected", "internal" and the other access modifiers.
For "protected internal" some places appear to say it means a union of
protected AND internal, other places say it's protected OR internal.
 
It's an OR.

From:
http://msdn.microsoft.com/library/d...y/en-us/csspec/html/vclrfcsharpspec_3_5_1.asp

The MSDN C# Reference.

-----------------

a.. Protected internal (meaning protected or internal), which is selected by
including both a protected and an internal modifier in the member
declaration. The intuitive meaning of protected internal is "access limited
to this program or types derived from the containing class".
-----------------
Also, From the C# Programmers Reference;

"protected internal
[...] Access is limited to the current assembly or types derived from
the containing class."


"Only one access modifier is allowed for a member or type, except for the
protected internal combination."

Hope it helps;

Josh

Microsoft.com Tools

Pete said:
Hello,

Can anyone provide advice/links on somewhere to get a definitive
explanation with Examples of how "protected internal" differs from
"protected", "internal" and the other access modifiers.
For "protected internal" some places appear to say it means a union of
protected AND internal, other places say it's protected OR internal.
 
For the benefit of us muggles/mortals:
protected internal is a union of protected and internal in terms of
providing access but not restricting.
Meaning
Inherited types, even though they belong to a different assembly, have
access to the protected internal members
Types that reside in the same assembly, even if they are not derived from
the type, also have access to the protected internal members
Sankar Nemani
 
Back
Top