Files
2nd/10_Wiki/Topics/Topic_Programming/Topic_CSharp/CSharp_Break.md
T
Antigravity Agent 9a135bd19d docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치.
콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서
전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한
업데이트0615/무제 3.canvas 뿐).
2026-07-05 00:44:01 +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).