DEV Community

Cover image for Access specifiers/modifiers in C#
Sharad Aade
Sharad Aade

Posted on

Access specifiers/modifiers in C#

Access specifiers define the visibility and accessibility of classes, methods, properties, fields, and other members within a program or project.
They control where members can be accessed.

  1. public
    Accessible from anywhere within the same assembly or another assembly.

  2. private
    Accessible only within the same class.
    Note:- Default access modifiers for class members.

  3. protected
    Accessible within the same class and derived classes(means inherited classes)

  4. internal
    Accessible only within the assembly (project) but not outside the assembly or project.
    Note:- Default for classes and structures(structs).

  5. protected internal
    Accessible within the same assembly/project, like internalor in a derived class in another assembly/project, like protected

Top comments (0)