Access Modifiers in C# :-access modifiers are used to define the scope of data and methods in the restricted manner. It protect data members of a class to outside interference.There are five types of access modifies in C# listed below:
(1). Public
(2).Private
(3). Protected
(4). Internal
(5). Protected internal Modifiers
(1) Public :- Public modifier allows public access to members both inside and outside the class.
(2) Private :- Private modifier allows the access of data members and member functions only inside the class in which they are declared , outside of class access is not allowed.
(3) Internal :- Internal modifier allows data access only to the current assembly , if a member is accessed outside the assembly in which it has been defined a error gets generated.
(4) Protected :- you can access the protected members inside the class in which they are declared or a class derived from that class in which they are declared.
(5) Protected Internal :- allows access to members containing in current assembly , containing class and the class derived from that class.
No comments:
Post a Comment