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

4.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-break C# Break and Continue Programming_Language draft conceptual
break continue C#
C# break continue
B 0.82 2026-07-04 2026-07-04
csharp
programming-language
w3schools
loops
break
continue
https://www.w3schools.com/cs/cs_break.php

CSharp Break

🎯 한 줄 통찰 (One-line insight)

This chapter explicitly ties break back to the Switch chapter ("You have already seen the break statement used... to jump out of a switch statement"), making the point that break is ONE keyword with TWO distinct jump targets (switch block vs. loop) — while continue is entirely new here, skipping only the CURRENT iteration rather than exiting entirely; both keywords and their exact semantics are identical to C/C++, but the while-loop continue example reveals a subtle placement rule: the increment (i++) must happen BEFORE continue inside a while loop (unlike a for loop, where the increment happens automatically), or the loop would spin forever on the skipped value. [S1]

🧠 핵심 개념 (Core concepts)

  • break — already introduced for exiting a switch block; here reused to exit a LOOP entirely (for or while), stopping all further iterations immediately. [S1]
  • continue — skips the REST of the current iteration only, then proceeds to the next iteration; does not exit the loop. [S1]
  • for loop placement — both break and continue are placed inside a conditional check (if (i == 4) { break; } / { continue; }) within the loop body. [S1]
  • while loop placement subtlety — in a while loop, continue must be preceded by the manual increment (i++; continue;), because continue jumps straight back to the condition check, skipping any code after it — including an increment that would otherwise appear later in the body. [S1]

📖 세부 내용 (Details)

  • break in a for loop: for (int i = 0; i < 10; i++) { if (i == 4) { break; } Console.WriteLine(i); } → prints 0,1,2,3 then stops entirely at 4. [S1]
  • continue in a for loop: for (int i = 0; i < 10; i++) { if (i == 4) { continue; } Console.WriteLine(i); } → prints 0,1,2,3,5,6,7,8,9 (skips only 4). [S1]
  • break in a while loop: increment happens BEFORE the break check (i++; if (i == 4) { break; }). [S1]
  • continue in a while loop: increment happens BEFORE continue is called (if (i == 4) { i++; continue; }), specifically to avoid an infinite loop that would otherwise keep re-testing i == 4 forever. [S1]

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

  • break가 switch와 loop 두 곳에서 재사용되는 동일 키워드임을 명시: 이번 챕터는 break가 switch 챕터에서 이미 배운 것과 같은 키워드이며, 단지 탈출 대상이 switch 블록에서 루프로 바뀔 뿐이라는 점을 직접 언급함 — C/C++와 마찬가지로 하나의 키워드가 문맥에 따라 다른 블록을 탈출하는 데 재사용됨. [S1]
  • while 루프에서 continue 앞에 증감식이 반드시 와야 함: for 루프는 증감(statement3)이 자동으로 실행되지만, while 루프는 continue가 조건 검사로 바로 점프하므로 continue보다 먼저 i++를 실행해두지 않으면 무한 루프가 발생한다는 점이 while 루프 continue 예제에서 확인됨. [S1]

🛠️ 적용 사례 (Applied in summary)

i==4일 때 루프를 완전히 탈출(break)하는 예제와, i==4만 건너뛰고 나머지는 계속 출력(continue)하는 예제가 for/while 양쪽 모두에서 원문에 직접 제시됨. [S1]

💻 코드 패턴 (Code patterns)

continue in a while loop — increment must come first to avoid infinite loop (C#):

int i = 0;
while (i < 10)
{
    if (i == 4)
    {
        i++;       // must increment BEFORE continue
        continue;
    }
    Console.WriteLine(i);
    i++;
}

검증 상태 및 신뢰도

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

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

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