Files
2nd/10_Wiki/Topic_Programming/Topic_CSharp/CSharp_While_Loop.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

3.9 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-while-loop C# While Loop Programming_Language draft conceptual
do while loop C#
C# while 반복문
B 0.83 2026-07-04 2026-07-04
csharp
programming-language
w3schools
loops
while
https://www.w3schools.com/cs/cs_while_loop.php

CSharp While Loop

🎯 한 줄 통찰 (One-line insight)

Both loop syntaxes on this page (while (condition) {...} and do {...} while (condition);) are identical to C/C++, and the source combines them into ONE chapter rather than splitting them across two — a structural choice that differs from Topic_CPP, where While Loop and Do While Loop were separate documents — meaning this single C# doc intentionally covers both variants together, matching the source page's own organization instead of forcing a 1:1 split that the source doesn't have. [S1]

🧠 핵심 개념 (Core concepts)

  • while (condition) { ... } — repeats the block as long as condition stays True; the condition is checked BEFORE each iteration, so the body may run zero times. [S1]
  • do { ... } while (condition); — the do/while variant; the block runs ONCE FIRST, then the condition is checked — meaning the body always executes at least once, even if the condition is false from the start. [S1]
  • Manual increment required — both loops require the loop variable to be manually advanced inside the body (i++); forgetting this creates an infinite loop, a warning the tutorial repeats for both variants. [S1]

📖 세부 내용 (Details)

  • While example: int i = 0; while (i < 5) { Console.WriteLine(i); i++; } → prints 0,1,2,3,4. [S1]
  • Do/while example: int i = 0; do { Console.WriteLine(i); i++; } while (i < 5); → identical output to the while version in this case, but the guarantee differs (body always runs at least once). [S1]

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

  • while/do-while이 C/C++와 완전히 동일한 문법·의미: 조건 선검사(while) vs 후검사(do-while) 구조와 문법이 C/C++와 차이가 없다는 점이 확인됨. [S1]
  • 원문 구조상 while과 do-while이 한 챕터로 묶여 있음: Topic_CPP에서는 While Loop와 Do While Loop가 별도 문서였지만, C# 사이드바는 이 둘을 cs_while_loop.php 하나의 페이지로 묶어 제공한다는 점이 확인됨 — 소스 사이트의 실제 챕터 구성을 그대로 따라 이 문서도 두 변형을 함께 다룸(1:1 매핑 원칙을 소스의 실제 챕터 단위에 맞춤). [S1]

🛠️ 적용 사례 (Applied in summary)

0부터 4까지 출력하는 동일한 로직을 while과 do/while 두 가지 방식으로 각각 구현하는 예제가 원문에서 나란히 제시됨. [S1]

💻 코드 패턴 (Code patterns)

while (pre-check) vs. do/while (post-check, runs at least once) (C#):

int i = 0;
while (i < 5)
{
    Console.WriteLine(i);
    i++;
}

int j = 0;
do
{
    Console.WriteLine(j);
    j++;
}
while (j < 5);

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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