---
id: csharp-access-modifiers
title: "C# Access Modifiers"
category: "Programming_Language"
status: "draft"
verification_status: "conceptual"
canonical_id: ""
aliases: ["public private protected internal C#", "C# 접근 제한자"]
duplicate_of: ""
source_trust_level: "B"
confidence_score: 0.85
created_at: 2026-07-04
updated_at: 2026-07-04
review_reason: ""
merge_history: []
tags: ["csharp", "programming-language", "w3schools", "oop", "access-modifiers"]
raw_sources: ["https://www.w3schools.com/cs/cs_access_modifiers.php"]
applied_in: []
github_commit: ""
---

# [[CSharp Access Modifiers]]

## 🎯 한 줄 통찰 (One-line insight)
C# adds a FOURTH access level — `internal` (accessible within the same assembly, not across assemblies) — that has no direct C++ equivalent, since "assembly" is a .NET-specific compiled-unit concept C++'s translation-unit/library model doesn't share; meanwhile `public`/`private`/`protected` carry the same meanings as C++, and the default-to-`private`-when-unspecified rule for class members is IDENTICAL to what Topic_CPP already confirmed for C++ classes — making `internal` (plus the two combinations `protected internal` and `private protected`, mentioned but deferred) the one genuinely new addition in this chapter. [S1]

## 🧠 핵심 개념 (Core concepts)
- **`public`** — accessible from ALL classes. [S1]
- **`private`** — accessible ONLY within the same class. [S1]
- **`protected`** — accessible within the same class OR classes that inherit from it (full detail deferred to Inheritance). [S1]
- **`internal`** — accessible only within its own ASSEMBLY, not from another assembly (detail deferred; no equivalent concept in C/C++ covered so far in this series). [S1]
- **Combined modifiers** — `protected internal` and `private protected` exist but aren't covered in depth here. [S1]
- **Default access = private** — if no access modifier is specified on a class member, it defaults to `private`. [S1]
- **Purpose** — controls visibility/security of class members, and enables Encapsulation (hiding sensitive data by making fields private, deferred to the next chapter). [S1]

## 📖 세부 내용 (Details)
- Private field, accessed from WITHIN its own class: works fine, prints `"Mustang"`. [S1]
- Private field, accessed from a DIFFERENT class (`Program`): compile error — `'Car.model' is inaccessible due to its protection level`. [S1]
- Public field, accessed from a different class: works, prints `"Mustang"`. [S1]
- Implicit private default: `class Car { string model; string year; }` — both fields are private even though no keyword is written. [S1]

## ⚖️ 모순 및 업데이트 (Contradictions & updates)
- **기본 접근 수준(private)은 C++와 동일**: 접근 제한자를 명시하지 않으면 private가 기본값이라는 규칙이 Topic_CPP의 Access Specifiers 챕터에서 확인된 규칙과 차이가 없다는 점이 확인됨. [S1]
- **internal은 C/C++에 대응 개념이 없는 새로운 접근 수준**: "같은 어셈블리 내에서만 접근 가능, 다른 어셈블리에서는 불가"라는 internal의 정의는 .NET의 컴파일 단위인 어셈블리 개념에 의존하며, 이 시리즈의 C/C++ 챕터에는 대응하는 개념이 없었다는 점이 새로운 차이로 확인됨. [S1]

## 🛠️ 적용 사례 (Applied in summary)
private 필드를 같은 클래스 안에서 접근할 때는 성공하고, 다른 클래스(Program)에서 접근하면 컴파일 에러가 나는 것을 대비해 보여주는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

## 💻 코드 패턴 (Code patterns)
private field inaccessible from another class — compile error (C#):
```csharp
class Car
{
    private string model = "Mustang";
}
class Program
{
    static void Main(string[] args)
    {
        Car myObj = new Car();
        Console.WriteLine(myObj.model);
        // Error: 'Car.model' is inaccessible due to its protection level
    }
}
```

## ✅ 검증 상태 및 신뢰도
- **상태:** draft
- **검증 단계:** conceptual
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
- **신뢰 점수:** 0.85
- **중복 검사 결과:** 신규 생성 (New discovery)

## 🔗 지식 그래프 (Knowledge Graph)
- **상위/루트:** [[C# Tutorial]]
- **관련 개념:** [[CSharp Constructors]], [[CSharp Properties]], [[CPP Access Specifiers]]
- **참조 맥락:** Access Modifiers & Properties 섹션 — Properties (Get and Set) 챕터로 이어짐.

## 📚 출처 (Sources)
- [S1] W3Schools — C# Access Modifiers — https://www.w3schools.com/cs/cs_access_modifiers.php

## 📝 변경 이력 (Change history)
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Access Modifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).
