Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_CSharp/CSharp_Properties.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

5.3 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-properties C# Properties (Get and Set) Programming_Language draft conceptual
get set C#
automatic properties C#
encapsulation C#
C# 프로퍼티
B 0.86 2026-07-04 2026-07-04
csharp
programming-language
w3schools
oop
properties
encapsulation
https://www.w3schools.com/cs/cs_properties.php

CSharp Properties

🎯 한 줄 통찰 (One-line insight)

This is the chapter where the .Length-is-a-property-not-a-method observation from way back in the Strings chapter finally gets explained: a C# property is a LANGUAGE-LEVEL construct combining a private field with get/set accessor blocks, and — unlike C++, which has no native property syntax and requires programmers to write plain getName()/setName() METHODS by convention — C# additionally offers "automatic properties" (public string Name { get; set; }) that need no backing field written at all, making encapsulation nearly free syntactically where C++ makes it entirely manual boilerplate. [S1]

🧠 핵심 개념 (Core concepts)

  • Encapsulation — hiding sensitive data by declaring fields private, then exposing controlled access through public get/set methods via properties. [S1]
  • Property — a hybrid of a variable and a method, containing a get accessor and a set accessor. [S1]
  • get accessor — returns the value of the associated private field. [S1]
  • set accessor — assigns a value to the associated private field; the special value keyword represents whatever value is being assigned to the property. [S1]
  • Naming convention — the property should share the field's name but start with an UPPERCASE letter (name field ↔ Name property). [S1]
  • Automatic (shorthand) propertiespublic string Name { get; set; } — no backing field declared manually; the compiler generates one implicitly, producing identical behavior with less code. [S1]
  • Encapsulation benefits — better control over class members, ability to make a field effectively read-only (get-only) or write-only (set-only), flexibility to change internals without breaking external code, and increased data security. [S1]

📖 세부 내용 (Details)

  • Full manual property: class Person { private string name; public string Name { get { return name; } set { name = value; } } }. [S1]
  • Usage: Person myObj = new Person(); myObj.Name = "Liam"; Console.WriteLine(myObj.Name);"Liam" — accessed via the SAME dot syntax as a plain field, even though a get/set pair runs underneath. [S1]
  • Automatic property equivalent: class Person { public string Name { get; set; } } — same usage, same output, but no explicit name field or accessor bodies written. [S1]

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

  • Strings 챕터의 .Length 프로퍼티 미스터리가 여기서 풀림: Topic_CSharp의 Strings 챕터에서 .Length가 괄호 없는 프로퍼티라고 확인했었는데, 이번 챕터가 프로퍼티의 실제 정의(private 필드 + get/set)를 설명함으로써 그 문법적 정체가 명확해짐. [S1]
  • C++에는 없는 언어 차원의 프로퍼티 문법: C++는 프로퍼티라는 언어 기능이 없어 getName()/setName() 같은 일반 메서드를 관례적으로 작성해야 했지만, C#은 get/set 접근자를 언어 문법으로 제공하며 심지어 자동 프로퍼티({ get; set; })로 백킹 필드조차 생략할 수 있다는 점이 확인됨 — 캡슐화 구현 비용이 C++보다 훨씬 낮음. [S1]

🛠️ 적용 사례 (Applied in summary)

Person 클래스의 private name 필드를 public Name 프로퍼티(get/set)로 감싸 외부에서 myObj.Name으로 안전하게 읽고 쓰는 예제, 그리고 이를 자동 프로퍼티로 축약한 동일 결과의 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Manual property vs. automatic (shorthand) property — same behavior (C#):

// Manual
class Person
{
    private string name;
    public string Name
    {
        get { return name; }
        set { name = value; }
    }
}

// Automatic (shorthand) -- no backing field written
class PersonShort
{
    public string Name { get; set; }
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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