Sunday 28 October 2012

What is Access Modifier? How many types of Access modifiers.


Access Modifier is a c sharp keyword. It is used for level of accessibility or scope of a class or its member.In other word , access modifier specifies the portion of program in which  class and its member can be legally used. With the help of access modifiers , we can either restrict or permit the class or its member.
There are four  types of Access modifiers:
1.)private:  Member that are defined with this access modifier are accessible within the class in which they are defined. Such member are not accessed outside the class.
2.)public:  Class or member that are defined with this access modifier are accessible anywhere in the program or application. These member  can be accessed  within the class, out the class and anywhere in the program or application.
3.)protected: Member  or class that are defined with this access modifier are accessible anywhere in the own class and its derived class. Such members can be consider in between the public and private access modifiers.
4.)internal:  Class or member that are defined with this modifier are accessible in the current assembly. This modifier is considered to be equivalent to the friend access modifier in c++.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.