Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Access_Modifiers.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

4.7 KiB

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

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 modifiersprotected 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#):

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C# Access Modifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).