C# Access Modifiers

Public - access to all.

Private - access limited to only with in the class.

Protected - access limited to with in the class and derived class.

Internal - access to all with in the same project assembly

Protected Internal - access to the same assembly and derived class.

Private Protected - access in the same class and derived class


ModifierDescription
publicThere are no restrictions on accessing public members.
privateAccess is limited to within the class definition. This is the default access modifier type if none is formally specified
protectedAccess is limited to within the class definition and any class that inherits from the class
internalAccess is limited exclusively to classes defined within the current project assembly
protected internalAccess is limited to the current assembly and types derived from the containing class. All members in current project and all members in derived class can access the variables.   
private protected
Access is limited to the containing class or types derived from the containing class within the current assembly.





Comments

Popular posts from this blog

C# | Association, Aggregation and Composition

Throw vs Throw ex in C#

String[] args in C#