What is an access modifier And its Types in C#
What is the access modifier?
Access modifiers are used to specify the scope of accessibility of a member of a class or type of the class itself. There are six different types of access modifiers.
Types of Acess Modifier in C#
a. Public:
Objects that implement public access modifiers are accessible from everywhere in a project without any restrictions.
b. Private:
Objects that implement private access modifier are accessible only inside a class or a structure. As a result, we can’t access them outside the class they are created.
c. Protected:
The protected keyword implies that the object is accessible inside the class and in all classes that derive from that class.
d. Internal:
For Internal keyword, the access is limited exclusively to classes defined within the current project assembly.
e. Protected Internal
The protected internal access modifier is a combination of protected and internal. As a result, we can access the protected internal member only in the same assembly or in a derived class in other assemblies.
f. Private Protected:
The private protected access modifier is a combination of the private and protected keywords. We can access members inside the containing class
No comments:
Post a Comment