All types and type members have an accessibility level. The accessibility level controls whether they can be used from other code in your assembly or other assemblies. An assembly is a .dll or .exe created by compiling one or more .cs files in a single compilation.
Definitions of Access Modifiers for C#:
- public: Code in any assembly can access this type or member. The accessibility level of the containing type controls the accessibility level of public members of the type.
- private: Only code declared in the same
classorstructcan access this member. - protected: Only code in the same
classor in a derivedclasscan access this type or member. - internal: Only code in the same assembly can access this type or member.
- protected internal: Only code in the same assembly or in a derived class in another assembly can access this type or member.
- private protected: Only code in the same assembly and in the same class or a derived class can access the type or member.
- file: Only code in the same file can access the type or member.
The record modifier on a type causes the compiler to synthesize extra members. The record modifier doesn't affect the default accessibility for either a record class or a record struct.
Summary of Access Modifiers for C#:

Default of Access Modifiers for C#:
- class --- internal
- members, including nested class and struct, --- private
- struct --- internal
- members, including nested class and struct, --- private
- delegate --- internal
- interface --- internal
- members --- public
References:

Mariusz PostolPosted Jul 29, 2024, 1:27 PM
@George, you said "All types and type members have an accessibility level. The accessibility level controls whether they can be used from other code in your assembly or other assemblies. An assembly is a .dll or .exe created by compiling one or more .cs files in a single compilation." - almost OK but let me give you a few notes: "accessibility level" == "visibility level"; "can be used" == "is visible by". If we are talking about the code (program text) we cannot talk at the same time about the result of the compiler converting compilation unit (project) and creating assemblies (.dll, .exe) - we must talk about projects and project dependencies because visibility in other projects depends on dependencies between projects. I think that an interesting question is what is the reason that there must not be bidirectional references between projects?