Different
Access Modifiers in C# are Public, Private, Protected, internal, protected
Internal.
Default access s modifier for members of class s is private.
Default Access
Modifiers in C #
Names
pace will not have access modifier.
Default
access modifier for Class, Struct, Interface, Enum, and Delegate is Internal.
Default
access modifier for class and Struct members is private.
No
access modifier can be applied to interface members and always interface
members are
Public.
Enum
members are always public and no access modifier can be applied.
Access Modifier Basics
An
access modifier is a keyword of the language that is used to specify the access
level of
Members
of a class . C#.net supports the following access modifiers.
Public:
W hen Members of a class are declared as public, and then they can
be accessed
1. within
the class in which they are declared.
2. within
the derived classes of that class available within the same assembly.
3. outside
the class within the same assembly.
4. within
the derived classes of that class available outside the assembly.
5. outside
the class outside the assembly.
Internal:
W hen Members of a class are declared as internal, then they can
be accessed
1. within
the class in which they are declared.
2. within
the derived classes of that class available within the same assembly.
3. outside
the class within the same assembly.
Protected:
W hen Members of a class are declared as protected, then they can
be Accessed
1. within
the class in which they are declared.
2. within
the derived classes of that class available within the same assembly.
3. within
the derived classes of that class available outside the assembly.
Protected
internal: W hen Members of a class are declared as
protected internal, then they
Can
be accessed
1. within
the class in which they are declared.
2. within
the derived classes of that class available within the same assembly.
3. outside
the class within the same assembly.
4. within
the derived classes of that class available outside the assembly.
Private:
Private members of a class are completely restricted and are
accessible only within
The
class in which they are declared.
No comments:
Post a Comment