Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_While_Loop.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +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).