The main purpose of using access specifiers is to provide security to the applications. The availability (scope) of the member objects of a class may be controlled using access specifiers.
PUBLIC
As the name specifies, it can be accessed from anywhere. If a member of a class is defined as public then it can be accessed anywhere in the class as well as outside the class. This means that objects can access and modify public fields, properties, methods.
PRIVATE
As the name suggests, it can't be accessed outside the class. Its the private property of the class and can be accessed only by the members of the class.
INTERNAL
Friend & Internal mean the same. Internal is used in C#. Friends can be accessed by all classes within an assembly but not from outside the assembly.
PROTECTED
Protected variables can be used within the class as well as the classes that inherites this class.
PROTECTED INTERNAL
The Protected Internal can be accessed by Members of the Assembly or the inheriting class, and ofcourse, within the class itself.
search
Subscribe to:
Post Comments (Atom)
1 comment:
thx for the posts,
Post a Comment