--- id: csharp-operators-comparison title: "C# Comparison Operators" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["== != > < 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", "operators", "comparison"] raw_sources: ["https://www.w3schools.com/cs/cs_operators_comparison.php"] applied_in: [] github_commit: "" --- # [[CSharp Comparison Operators]] ## 🎯 한 줄 통찰 (One-line insight) C#'s comparison operators return a genuine `bool` value (`True`/`False`), not C's convention of `1`/`0` integers standing in for truth — this is a direct, visible consequence of the Data Types chapter's earlier finding that `bool` is a real first-class type in C# (unlike classic C, where comparisons are just `int` expressions), so `Console.WriteLine(x > y);` prints the WORD "True", something a raw C comparison expression could never do without an explicit `? "true" : "false"` ternary. [S1] ## 🧠 핵심 개념 (Core concepts) - **`==`** — equal to. [S1] - **`!=`** — not equal. [S1] - **`>` / `<`** — greater than / less than. [S1] - **`>=` / `<=`** — greater than or equal to / less than or equal to. [S1] - **Return type is `bool`** — every comparison evaluates to a true `bool` value (`True` or `False`), not an integer. [S1] - **Purpose** — enables decision-making in code; foundational for the upcoming Conditions (if/else) chapters. [S1] ## 📖 세부 내용 (Details) - Direct example: `int x = 5; int y = 3; Console.WriteLine(x > y); // returns True because 5 is greater than 3`. [S1] ## ⚖️ 모순 및 업데이트 (Contradictions & updates) - **비교 결과가 진짜 bool 값으로 출력됨**: C의 비교식은 사실 int(1 또는 0)를 반환하므로 `printf`로 직접 출력하면 1/0이 찍히지만, C#은 bool이 실질적인 타입이라 `Console.WriteLine(x > y);`가 "True"라는 단어 자체를 출력한다는 점이 확인됨 — Data Types 챕터에서 확인된 bool의 1급 타입 지위가 여기서 실제로 드러남. [S1] ## 🛠️ 적용 사례 (Applied in summary) 현재 발견된 실제 적용 사례가 없습니다 — x > y 비교 결과를 직접 출력하는 예제가 원문에서 제시됨. [S1] ## 💻 코드 패턴 (Code patterns) Comparison operators return real bool values, printed as "True"/"False" (C#): ```csharp int x = 5; int y = 3; Console.WriteLine(x > y); // "True" ``` ## ✅ 검증 상태 및 신뢰도 - **상태:** draft - **검증 단계:** conceptual - **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body) - **신뢰 점수:** 0.83 - **중복 검사 결과:** 신규 생성 (New discovery) ## 🔗 지식 그래프 (Knowledge Graph) - **상위/루트:** [[C# Tutorial]] - **관련 개념:** [[CSharp Operators Assignment]], [[CSharp Operators Logical]], [[CSharp Data Types]] - **참조 맥락:** Operators 섹션의 마지막 챕터 — Math 섹션으로 이어짐. ## 📚 출처 (Sources) - [S1] W3Schools — C# Comparison Operators — https://www.w3schools.com/cs/cs_operators_comparison.php ## 📝 변경 이력 (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C# Comparison Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).