Files
2nd/10_Wiki/Topics/Domain_Programming/Topic_CSharp/CSharp_Arrays.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.0 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-arrays C# Arrays Programming_Language draft conceptual
array declaration C#
new keyword arrays
C# 배열
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
arrays
https://www.w3schools.com/cs/cs_arrays.php

CSharp Arrays

🎯 한 줄 통찰 (One-line insight)

C#'s array declaration puts the brackets right after the TYPE (string[] cars;), not after the variable name like C's char cars[4]; — a real syntactic divergence hiding under superficial similarity, and the tutorial explicitly documents FOUR equivalent ways to construct the same array (bare braces, new type[size], new type[size] {...}, new type[] {...}), while also stating a hard rule the C family never needed: if you declare an array first and assign its values LATER (in a separate statement), the new keyword becomes MANDATORY — omitting it is a compile error, unlike C where separate declaration and initialization of an array is simply not possible with a brace list at all. [S1]

🧠 핵심 개념 (Core concepts)

  • Declaration syntaxtype[] variableName; — brackets attach to the TYPE, not the variable name (contrast with C's type variableName[size];). [S1]
  • Array literalstring[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; — values in a comma-separated, brace-wrapped list. [S1]
  • Index access, 0-basedcars[0] is the first element, same convention as every prior language in this series. [S1]
  • Mutable elementscars[0] = "Opel"; overwrites an existing element directly. [S1]
  • .Length property — no parentheses, matching the string .Length property's design (property, not method). [S1]
  • Four equivalent construction forms: new string[4] (empty, size 4), new string[4] {...} (size + values), new string[] {...} (values, size inferred), and bare {...} (values, size inferred, no new). [S1]
  • new becomes mandatory when assigning after declarationstring[] cars; cars = new string[] {"Volvo", "BMW", "Ford"}; works, but cars = {"Volvo", "BMW", "Ford"}; (without new) is a compile error. [S1]

📖 세부 내용 (Details)

  • Access: string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; Console.WriteLine(cars[0]); // Volvo. [S1]
  • Modify: cars[0] = "Opel"; Console.WriteLine(cars[0]); // Opel. [S1]
  • Length: Console.WriteLine(cars.Length); // 4. [S1]

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

  • 대괄호가 변수명이 아니라 타입에 붙음: C의 배열 선언은 char cars[4];처럼 대괄호가 변수명 뒤에 붙었지만, C#은 string[] cars;처럼 타입 바로 뒤에 대괄호가 붙는다는 점이 확인됨 — 표면적으로 비슷해 보이지만 실제 문법 위치가 다름. [S1]
  • 선언 후 대입 시 new가 필수가 됨: 선언과 초기화를 분리할 경우(string[] cars; 이후 cars = {...};) 중괄호만으로는 컴파일 에러가 나고 반드시 new string[] {...}처럼 new를 붙여야 한다는 규칙이 확인됨 — C는애초에 배열을 선언 후 별도 문장에서 중괄호 리스트로 재할당하는 것 자체가 불가능하므로 C에는 없던 규칙. [S1]

🛠️ 적용 사례 (Applied in summary)

자동차 이름 배열을 선언하고, 첫 원소를 읽고 바꾸고, 길이를 확인하는 기본 흐름이 원문에서 직접 실전 활용 사례로 제시됨. [S1]

💻 코드 패턴 (Code patterns)

Four equivalent array construction forms, and the mandatory new on later assignment (C#):

string[] cars1 = new string[4];                              // empty, size 4
string[] cars2 = new string[4] {"Volvo", "BMW", "Ford", "Mazda"};
string[] cars3 = new string[] {"Volvo", "BMW", "Ford", "Mazda"};
string[] cars4 = {"Volvo", "BMW", "Ford", "Mazda"};           // no `new` needed here

string[] cars5;
cars5 = new string[] {"Volvo", "BMW", "Ford"};  // new REQUIRED when assigned separately
// cars5 = {"Volvo", "BMW", "Ford"};            // error without new

검증 상태 및 신뢰도

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