Private Protected (Visual Basic)
Private Protected keyword combination is a member access modifier. A
Private Protected member is accessible by all members in its containing class, as well as by types derived from the containing class, but only if they are found in its containing assembly.
You can specify
Private Protected only on members of classes; you cannot apply
Private Protected to members of a structure because structures cannot be inherited.
Private Protected access modifier is supported by Visual Basic 15.5 and later. To use it, you can add the following element to your Visual Basic project (*.vbproj) file. As long as Visual Basic 15.5 or later is installed on your system, it lets you take advantage of all the language features supported by the latest version of the Visual Basic compiler:
<PropertyGroup> <LangVersion>latest</LangVersion> </PropertyGroup>
For more information see setting the Visual Basic language version.
- Declaration Context. You can use
Private Protectedonly at the class level. This means the declaration context for a
Protectedelement must be a class, and cannot be a source file, namespace, interface, module, structure, or procedure.
Access Level. All code in a class can access its elements. Code in any class that derives from a base class and is contained in the same assembly can access all the
Private Protectedelements of the base class. However, code in any class that derives from a base class and is contained in a different assembly can't access the base class
Access Modifiers. The keywords that specify access level are called access modifiers. For a comparison of the access modifiers, see Access levels in Visual Basic.
Private Protected modifier can be used in these contexts:
Class Statement of a nested class
Delegate Statement of a delegate nested in a class
Enum Statement of an enumeration nested in a class
Interface Statement of an interface nested in a class
Structure Statement of a structure nested in a class