Wednesday, November 28, 2012

Access Modifiers in C#.NET



Public
Member can be accessed by any other code in the same assembly or from another assembly that reference it.

Private
Member can only be accessed by the code in the same class or struct.

Protected
Member can be accessed by the code in the same class or struct and also by the code in a derived class.

Internal
Member can be access by the code in the same assembly but not by the code in a different assembly.

Protected internal
Member can be accessed by the code in the same assembly or the code in another assembly which inherits the class.

Static
Static classes cannot be instantiated and all the members are static. If the method is static and the class is not static then the method can be accessed without creating a instance of the class.  

No comments:
Write comments
Recommended Posts × +