Access modifier | Access level granted | Elements you can declare with this access level | Declaration context within which you can use this modifier |
public | Unrestricted: Any code that can see a public element can access it | Interfaces Modules Classes Structures Structure members Procedures Properties Member variables Constants Enumerations Events External declarations Delegates | Source file Namespace Interface Module Class Structure |
protected | Derivational: Code in the class that declares a protected element, or a class derived from it, can access the element | Interfaces Classes Structures Procedures Properties Member variables Constants Enumerations Events External declarations Delegates | Class |
internal | Assembly: Code in the assembly that declares an Internal element can access it | Interfaces Modules Classes Structures Structure members Procedures Properties Member variables Constants Enumerations Events External declarations Delegates | Source file Namespace Interface Module Class Structure |
protectedinternal | Code in the same class or the same assembly as a protected Internal element, or within any class derived from the element's class, can access it The protectedinternal accessibility means protected OR internal, not protected AND internal. In other words, a protectedinternal member is accessible from any class in the same assembly, including derived classes. To limit accessibility to only derived classes in the same assembly, declare the class itself internal, and declare its members as protected. | Interfaces Classes Structures Procedures Properties Member variables Constants Enumerations Events External declarations Delegates | Class |
private | Declaration context: Code in the type that declares a private element, including code within contained types, can access the element | Interfaces Classes Structures Structure members Procedures Properties Member variables Constants Enumerations Events External declarations Delegates | |
Saturday, November 15, 2008
Access Modifiers Comparison in Visual Basic .NET (VB.NET)
Keywords that specify access level are called as Access Modifers (e.g., Private, Public, Friend etc). Comparison of access levels of different keywords is given below:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment