Beginners Guide: Scoping of Methods

There are four basic scoping modifiers for methods (subs or functions) that are most used in ASP.Net/VB.Net. The are:

  • Private
  • Protected
  • Friend
  • Public

Beginning programmers sometimes have a problem understanding exactly what they are used for. These words are put in front of the Sub or Function. The base functionality is that these modifiers are defining the ‘scope’ in which they are used – in other words, where and how they can be used within the program in which they reside. The following is just a basic run down of what they mean.

Private
Private means that the sub or function is ONLY available/visible to the current class itself.

Protected
Protected means that the sub or function is ONLY available/visible to the current class AND subclasses derived from it.

Friend
Friend means that the sub or function is visible to the current assembly

Public
Public means that the sub or function is visible to all, and can be utilized as such.
Continues…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>