Access modifiers specifies access level for a type or type member. C# has 4 access modifiers,
- public
- protected
- internal
- private
- Access modifiers are not allowed on namespaces.
- Top level types which are not nested in other types can only have internal or public accessibility. The default is internal
public
access modifier for types and type members. There is no restriction for accessing public members.protected
Is a member access modifier. A protected member is accessible within it's class and derived class type.Since structs cannot be inherited its members cannot be protected. You can create protected classes as nested classes
internal
Access modifier for types and type members. Internal types or members are accessible within files of the same assembly.Types or members with access modifier protected internal can be accessed within same assembly or through the types derived from containing class.
private
Member access modifier. Private members are accessible only within body of the class or the struct. Nested types also can access private members.Resources
Access Modifiers
0 comments:
Post a Comment