Files
2nd/10_Wiki/Topic_Programming/Topic_CSharp/CSharp_Inheritance.md
T
Antigravity Agent e9cbf23ab5 docs(10_Wiki): Dev 폴더 누락분 반영 — Topic_Programming으로 통합
이전 재구성 작업에서 Dev/ 폴더가 누락되었던 것을 반영.

- Dev/Topic_Programming(중첩 폴더, 78개)은 Dev 자체 최상위 폴더들
  (Architecture/Conventions/Engineering_Intelligence 등)과 완전 중복이라 제거.
- Dev 최상위 엔지니어링 지식 폴더(Architecture/Conventions/Engineering_Intelligence/
  Failure_Library/Generalized_Principles/Language/Pattern_Catalog/Platform_Guides/
  Subsystems, 77개)는 이미 Topic_Programming/Topic_Programming에 더 최신 버전이
  존재해 중복 제거(고유 콘텐츠 1개는 예외 처리하여 이동 보존).
- Dev의 W3Schools 언어 튜토리얼 폴더(Topic_C/CPP/CSS/CSharp/HOWTO/HTML/Java/
  JavaScript/PHP/Python/SQL/W3CSS, 1201개)는 전부 Topic_Programming 하위로 이동.
- 에이전트 운영 상태(.astra/docs)는 그대로 유지, 콘텐츠 폴더만 정리.
- Topic_Programming 최종 문서 수: 2784 → 3985.
2026-07-05 00:39:13 +09:00

5.2 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-inheritance C# Inheritance Programming_Language draft conceptual
derived base class C#
sealed keyword C#
C# 상속
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
oop
inheritance
https://www.w3schools.com/cs/cs_inheritance.php

CSharp Inheritance

🎯 한 줄 통찰 (One-line insight)

C#'s inheritance syntax class Car : Vehicle OMITS the access specifier that C++'s equivalent class Car : public Vehicle REQUIRES — C# never lets you write class Car : private Vehicle, because member-level access (public/private/protected on each field/method) is the only lever C# offers, unlike C++ which layers an ADDITIONAL access specifier onto the inheritance relationship itself; and where C++ uses final to block further subclassing, C# uses a differently-named but functionally identical sealed keyword. [S1]

🧠 핵심 개념 (Core concepts)

  • Derived class (child) — the class that inherits from another class. [S1]
  • Base class (parent) — the class being inherited from. [S1]
  • : syntaxclass Car : Vehicle — no access specifier before the base class name, unlike C++'s class Car : public Vehicle. [S1]
  • Inherited members — a derived class gains ALL fields and methods from its base class, callable/accessible directly on the derived class's own objects. [S1]
  • Motivation — code reusability: reuse an existing class's fields/methods instead of rewriting them in the new class. [S1]
  • sealed keyword — prevents a class from being inherited at all; attempting to derive from a sealed class is a compile error ('Car': cannot derive from sealed type 'Vehicle'). [S1]

📖 세부 내용 (Details)

  • Full example: class Vehicle { public string brand = "Ford"; public void honk() { Console.WriteLine("Tuut, tuut!"); } } class Car : Vehicle { public string modelName = "Mustang"; } ... Car myCar = new Car(); myCar.honk(); Console.WriteLine(myCar.brand + " " + myCar.modelName); → calls the PARENT's honk() and reads the PARENT's brand field directly on a Car object, alongside Car's own modelName. [S1]
  • Sealed class blocking inheritance: sealed class Vehicle { ... } class Car : Vehicle { ... } → compile error. [S1]
  • The tutorial explicitly points forward to Polymorphism as building on inherited methods to perform different tasks. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

  • 상속 문법에 접근 지정자가 없음: C++는 class Car : public Vehicle처럼 상속 관계 자체에 public/private/protected 접근 지정자를 붙여야 했지만, C#은 class Car : Vehicle처럼 이 지정자 없이 상속하며, 접근 제어는 오직 멤버 단위(각 필드/메서드의 public/private/protected)로만 이뤄진다는 점이 확인됨. [S1]
  • final 대신 sealed라는 다른 이름의 동일 개념: C++11의 final 키워드와 동일한 역할(더 이상 상속 불가)을 C#은 sealed라는 이름으로 제공한다는 점이 확인됨 — 개념은 같지만 키워드가 다름. [S1]
  • 원문 구조상 상속이 단일 챕터로 압축됨: Topic_CPP는 Inheritance/Access/Multilevel/Multiple을 4개 문서로 나눴지만, C# 사이드바는 cs_inheritance.php 단 하나로 기본 상속과 sealed를 모두 다룬다는 점이 확인됨 — 다단계·다중 상속에 대한 별도 챕터가 C# 튜토리얼에는 없음. [S1]

🛠️ 적용 사례 (Applied in summary)

Vehicle(부모)의 brand 필드와 honk() 메서드를 Car(자식)가 상속받아 Car 객체에서 그대로 사용하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Inheritance without an access specifier on the base class (C#):

class Vehicle
{
    public string brand = "Ford";
    public void honk()
    {
        Console.WriteLine("Tuut, tuut!");
    }
}
class Car : Vehicle   // no `public`/`private` before Vehicle, unlike C++
{
    public string modelName = "Mustang";
}

Car myCar = new Car();
myCar.honk();                                        // inherited method
Console.WriteLine(myCar.brand + " " + myCar.modelName); // inherited field + own field

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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