> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/notes/languages/c-sharp/keywords/modifiers/access-modifiers.md).

# Access Modifiers

#### How is encapsulation done in C#?

Access specifiers/modifiers help implement Encapsulation in C#.

<table><thead><tr><th width="229">Declared accessibility</th><th>Meaning</th></tr></thead><tbody><tr><td><code>public</code></td><td>Access is not restricted.</td></tr><tr><td><code>internal</code></td><td>Access is limited to the current assembly.</td></tr><tr><td><code>protected</code></td><td>Access is limited to the containing class or types derived from the containing class.</td></tr><tr><td><code>private</code></td><td>Access is limited to the containing type (<code>class</code> or <code>struct</code>).</td></tr><tr><td><code>protected internal</code></td><td>Access is limited to the current assembly or types derived from the containing class.</td></tr><tr><td><code>private protected</code></td><td>Access is limited to the containing class or types derived from the containing class within the current assembly.</td></tr></tbody></table>

{% hint style="info" %}
An assembly is a *`.dll`* or *`.exe`* created by compiling one or more *`.cs`* files in a single compilation.
{% endhint %}

Top-level types, which are not nested in other types, can only have `internal` or `public` accessibility. The default accessibility for these types is `internal`.

<table><thead><tr><th width="145.33333333333331">Members of</th><th width="255">Default member accessibility</th><th>Allowed declared accessibility of the member</th></tr></thead><tbody><tr><td><code>enum</code></td><td><code>public</code></td><td>None</td></tr><tr><td><code>class</code></td><td><code>private</code></td><td><code>public</code><br><code>protected</code><br><code>internal</code><br><code>private</code><br><code>protected internal</code><br><code>private protected</code></td></tr><tr><td><code>interface</code></td><td><code>public</code></td><td><code>public</code><br><code>protected</code><br><code>internal</code><br><code>private</code><strong>*</strong><br><code>protected internal</code><br><code>private protected</code></td></tr><tr><td><code>struct</code></td><td><code>private</code></td><td><code>public</code><br><code>internal</code><br><code>private</code></td></tr></tbody></table>

{% hint style="warning" %}
**\*** An `interface` member with `private` accessibility must have a default implementation.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://dailyjournal.gitbook.io/notes/languages/c-sharp/keywords/modifiers/access-modifiers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
