Using Component (Access Modifier Types) in ASP.Net: Part 9

Introduction on Access Modifiers

Basically Access Modifier is keyword which is used in class to allow or restrict the accessibility. Visual Basic supports the following access modifiers (also called access levels), which we can use when declaring a class, method, or property:

  • Public: A Public class, method, or property has no access restrictions.
  • Private: A Private class, method, or property can be accessed only within the class itself.
  • Protected: A Protected method or property can be accessed only within the class itself or a derived class.
  • Friend/Internal: A Friend class, method, or property can be accessed only by a component within the same assembly (dll file). Because ASP.NET pages are compiled into different assemblies than the contents of the App_Code folder, we cannot access a Friend member of a class outside of the App_Code folder.
  • Protected Friend/Protected Internal: A Protected Friend method or property can be accessed within the class itself or a derived class, or any other class located in the same assembly.

Using access modifiers is useful when we are developing a component library that might be used by other members of our development team or by self in future. For example, we should mark all methods that we don't want to expose from our component as private.

Note: Continue in Next Part.

HAVE A GREAT CODING!


Similar Articles