Monday 2 June 2014

Access Modifiers

·    Scope of  Access Modifiers



           public 
-No restrictions to access
-The type or member can be accessed by any other code in the same assembly or another assembly that references it. 
      - We can use this modifier for Class.


·         protected 
-Access is limited to within the class definition and any class that inherits from the class.
-The type or member can be accessed only by code in the same class or struct, or in a class that is derived from that class.
      - Class did not support this access modifier.




·         internal 
-Access is limited exclusively to classes defined within the current project assembly.
-The type or member can be accessed only by code in the same class or struct. 
      - Class default access modifier is internal.  

·         private 
-Access is limited to within the class definition; This is the default access modifier type if none is formally specified.
-The type or member can be accessed by any code in the same assembly, but not from another assembly.
     -Class did not support this access modifier.

·         protected internal
 - The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. 
- Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
- Class did not support this access modifier.