1cfd3bbb56
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
82 lines
4.4 KiB
Markdown
82 lines
4.4 KiB
Markdown
---
|
|
id: csharp-booleans
|
|
title: "C# Booleans"
|
|
category: "Programming_Language"
|
|
status: "draft"
|
|
verification_status: "conceptual"
|
|
canonical_id: ""
|
|
aliases: ["bool data type C#", "boolean expressions C#", "C# 불리언"]
|
|
duplicate_of: ""
|
|
source_trust_level: "B"
|
|
confidence_score: 0.83
|
|
created_at: 2026-07-04
|
|
updated_at: 2026-07-04
|
|
review_reason: ""
|
|
merge_history: []
|
|
tags: ["csharp", "programming-language", "w3schools", "booleans"]
|
|
raw_sources: ["https://www.w3schools.com/cs/cs_booleans.php"]
|
|
applied_in: []
|
|
github_commit: ""
|
|
---
|
|
|
|
# [[CSharp Booleans]]
|
|
|
|
## 🎯 한 줄 통찰 (One-line insight)
|
|
This chapter previews the if...else statement (voting-age example) BEFORE the Conditions section formally covers it, which is a deliberate pedagogical sequencing choice — showing WHY boolean expressions matter (they're the direct input to `if`) before teaching the `if` syntax itself — and the example itself reuses `Console.WriteLine(myAge >= votingAge);` printing a raw `True`/`False` before wrapping the identical comparison inside an `if {} else {}` block, making the connection between "a boolean expression" and "a branching decision" explicit and concrete rather than assumed. [S1]
|
|
|
|
## 🧠 핵심 개념 (Core concepts)
|
|
- **`bool`** — a type that can only hold `true` or `false`, used for binary-state situations (yes/no, on/off). [S1]
|
|
- **Boolean expression** — an expression (typically built with comparison operators) that itself evaluates to `True`/`False`, e.g. `x > y`, `x == 10`. [S1]
|
|
- **Direct literal comparison** — comparisons work on literals too, not just variables: `Console.WriteLine(10 > 9);` is valid on its own. [S1]
|
|
- **Boolean expressions are the foundation of `if`/`else`** — the tutorial explicitly states "the boolean value of an expression is the basis for all C# comparisons and conditions." [S1]
|
|
|
|
## 📖 세부 내용 (Details)
|
|
- Direct declaration: `bool isCSharpFun = true; bool isFishTasty = false;` — printed as `True`/`False`. [S1]
|
|
- Comparison-derived booleans: `int x = 10; int y = 9; Console.WriteLine(x > y); // True`; `Console.WriteLine(x == 10); // True`; `Console.WriteLine(10 == 15); // False`. [S1]
|
|
- Real-life voting-age example, first as a bare boolean print: `int myAge = 25; int votingAge = 18; Console.WriteLine(myAge >= votingAge);` → `True`. [S1]
|
|
- The SAME comparison then wrapped in a full if/else:
|
|
```
|
|
if (myAge >= votingAge) { Console.WriteLine("Old enough to vote!"); }
|
|
else { Console.WriteLine("Not old enough to vote."); }
|
|
```
|
|
[S1]
|
|
|
|
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
|
- **if/else 문법이 정식 챕터 전에 미리 사용됨**: Conditions 섹션에서 if...else를 formal하게 다루기 전에, 이 챕터가 투표 연령 예제를 통해 if/else 구문을 먼저 보여준다는 점이 확인됨 — "왜 boolean 표현식이 중요한가(if의 입력이기 때문)"를 문법을 가르치기 전에 개념적으로 먼저 연결하려는 의도적 구성. [S1]
|
|
|
|
## 🛠️ 적용 사례 (Applied in summary)
|
|
투표 가능 연령(18세)과 실제 나이(25세)를 비교해 먼저 bool 값을 출력하고, 그다음 동일 비교를 if...else로 감싸 "Old enough to vote!" 또는 "Not old enough to vote."를 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
|
|
|
## 💻 코드 패턴 (Code patterns)
|
|
Boolean expression as a bare print, then wrapped in if/else (C#):
|
|
```csharp
|
|
int myAge = 25;
|
|
int votingAge = 18;
|
|
|
|
Console.WriteLine(myAge >= votingAge); // bare boolean -> True
|
|
|
|
if (myAge >= votingAge) {
|
|
Console.WriteLine("Old enough to vote!");
|
|
} else {
|
|
Console.WriteLine("Not old enough to vote.");
|
|
}
|
|
```
|
|
|
|
## ✅ 검증 상태 및 신뢰도
|
|
- **상태:** draft
|
|
- **검증 단계:** conceptual
|
|
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
|
- **신뢰 점수:** 0.83
|
|
- **중복 검사 결과:** 신규 생성 (New discovery)
|
|
|
|
## 🔗 지식 그래프 (Knowledge Graph)
|
|
- **상위/루트:** [[C# Tutorial]]
|
|
- **관련 개념:** [[CSharp Strings Chars]], [[CSharp Conditions]], [[CSharp Operators Comparison]]
|
|
- **참조 맥락:** Booleans 섹션의 유일 챕터 — Conditions 섹션으로 이어짐.
|
|
|
|
## 📚 출처 (Sources)
|
|
- [S1] W3Schools — C# Booleans — https://www.w3schools.com/cs/cs_booleans.php
|
|
|
|
## 📝 변경 이력 (Change history)
|
|
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Booleans" page (Astra wiki-curation, P-Reinforce v3.1 format).
|