Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_CSharp/CSharp_Enums.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.4 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-enums C# Enum Programming_Language draft conceptual
enumerations C#
enum switch C#
C# 열거형
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
enums
https://www.w3schools.com/cs/cs_enums.php

CSharp Enums

🎯 한 줄 통찰 (One-line insight)

Console.WriteLine(myVar) on a C# enum prints the symbolic NAME ("Medium"), not the underlying integer — a real behavioral difference from C++'s enum, which prints its raw integer value when streamed through cout << unless a custom conversion is written, meaning C# enums carry name-string-printability as a built-in feature (via an implicit ToString()) where C++ requires the programmer to bridge that gap manually; the auto-incrementing 0/1/2... numbering and the ability to override a starting value (which cascades to all subsequent members) otherwise matches the C++ enum model already documented in [[CPP Enum]]. [S1]

🧠 핵심 개념 (Core concepts)

  • enum keyword — declares an enum instead of class/interface; members separated by commas, no explicit values required. [S1]
  • Dot syntax accessLevel myVar = Level.Medium; — same pattern as accessing a static class member. [S1]
  • Printing an enum prints its NAMEConsole.WriteLine(myVar); outputs "Medium", not a number. [S1]
  • Default integer values — the first member is 0, the second 1, and so on, incrementing automatically. [S1]
  • Explicit cast to get the integer(int) Months.April is required to retrieve the underlying numeric value; it isn't exposed by default. [S1]
  • Custom starting values cascade forward — assigning a value to one member (e.g. March = 6) shifts every SUBSEQUENT member's auto-incremented value accordingly (April becomes 7, not 3). [S1]
  • Enums inside a class — an enum can be declared as a member of a class, scoped to it. [S1]
  • Enums in switch — a natural fit for switch statements, matching each case against an enum member. [S1]
  • Use case — values known never to change: month names, weekdays, colors, card suits, etc. [S1]

📖 세부 내용 (Details)

  • Basic declaration + access: enum Level { Low, Medium, High } ... Level myVar = Level.Medium; Console.WriteLine(myVar);"Medium". [S1]
  • Enum inside a class: class Program { enum Level { Low, Medium, High } static void Main(string[] args) { Level myVar = Level.Medium; Console.WriteLine(myVar); } }"Medium". [S1]
  • Default numbering + explicit cast: enum Months { January, February, March, April, May, June, July } ... int myNum = (int) Months.April;3 (0-indexed). [S1]
  • Custom starting value cascading: enum Months { January, February, March=6, April, May, June, July } ... int myNum = (int) Months.April;7 (March=6 shifts April to 7, not the default 3). [S1]
  • Switch on enum: switch(myVar) { case Level.Low: ...; break; case Level.Medium: Console.WriteLine("Medium level"); break; case Level.High: ...; break; }"Medium level". [S1]

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

  • enum을 출력하면 이름이 나옴(C++와 다름): C++에서 enum을 cout <<으로 출력하면 기본적으로 정수값이 나오지만(별도 변환 없이는 이름이 출력되지 않음), C#은 Console.WriteLine(myVar)가 곧바로 심볼릭 이름("Medium")을 출력한다는 점이 확인됨 — C#의 enum이 기본적으로 문자열 표현을 내장하고 있음을 보여줌. [S1]
  • 자동 증가·수동 재지정 방식은 C++의 enum과 동일: 첫 멤버가 0부터 시작해 자동 증가하고, 특정 멤버에 값을 수동으로 지정하면 그 이후 멤버들이 그 값을 기준으로 다시 증가한다는 규칙이 [[CPP Enum]]에서 확인된 C++ enum 규칙과 차이가 없다는 점이 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

Level enum(Low/Medium/High)을 switch문에서 각 case와 매칭시켜 해당 레벨 메시지를 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Printing an enum prints its name; explicit cast needed for the integer value (C#):

enum Level { Low, Medium, High }

Level myVar = Level.Medium;
Console.WriteLine(myVar);        // "Medium" -- name, not a number

int myNum = (int) Level.Medium;  // explicit cast required
Console.WriteLine(myNum);        // 1

검증 상태 및 신뢰도

  • 상태: 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# Enum" page (Astra wiki-curation, P-Reinforce v3.1 format).