Windows Phone Developers

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:

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

Friend

Assembly:

Code in the assembly that declares a friend 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

ProtectedFriend

Union of Protected and Friend:

Code in the same class or the same assembly as a protected friend element, or within any class derived from the element's class, can access it

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


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment