Saturday, May 22, 2010

Access Specifiers

Scope of the variables

  • Public -- Public access modifier can be set to a class / method / property to make it visible to any class / any assembly.
  • Private -- Private can be set to those fields which are within the class and they are used to hide from outside of the class.
  • Protected -- Protected is used for immediate child classes.
  • Internal -- Internal is used specifically for within the assembly.
  • Protected Internal -- It is used for within the assembly and assembly that inherits this assembly (Shared Assembly).
  • Static @ Modifier -- Static member belongs to the class and as such we don't need to create an object to access it.
  • Non-static member - Default, can be accessed only via an object of the class.
    Real time: WriteLine() is a static function in Console as we did not create an object that looks like Console to access it.

0 comments:

Post a Comment