--- 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).