Access Modifiers in C#.Net

Access Modifiers are used to control what our class objects can access its own fields or methods if  they are created in some other classes
  • Public 
  • Private
  • Internal
  • Protected
  • Protected Internal
Public:
public fields or methods is accessible from all classes every where

Private:
Private fields or methods is accessible only with in its own class

Internal:
Internal fields or methods is accessible from all classes defined in the same assembly

Protected:
Protected fields or methods can be accessed by its objects with in the same class or derived classes

Protected Internal:
Protected fields or methods can be accessed by its objects in all classes with in the same assembly or by derived classes from other assembly


No comments:

Post a Comment