docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고, Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: csharp-conditions-shorthand
|
||||
title: "C# Short Hand If...Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["ternary operator C#", "? : C#", "C# 삼항 연산자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.82
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "conditions", "ternary"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_conditions_shorthand.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Conditions Shorthand]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The ternary operator syntax `variable = (condition) ? expressionTrue : expressionFalse;` is identical to C and C++'s `? :` operator, and the tutorial demonstrates it by directly collapsing the SAME time/greeting `if/else` example from the previous two chapters into one line — making this chapter function as a running "before/after" refactor of the exact code just taught, rather than a standalone new example. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Ternary operator (`? :`)** — called "short-hand if...else" here, consists of three operands (hence "ternary"), replacing a full `if/else` block with a single expression. [S1]
|
||||
- **Syntax**: `variable = (condition) ? expressionTrue : expressionFalse;`. [S1]
|
||||
- **Use case** — best suited for SIMPLE if/else logic that just assigns one of two values; not intended to replace complex multi-branch logic. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full if/else form (identical to the `else` chapter's example): `int time = 20; if (time < 18) { Console.WriteLine("Good day."); } else { Console.WriteLine("Good evening."); }`. [S1]
|
||||
- Ternary equivalent: `int time = 20; string result = (time < 18) ? "Good day." : "Good evening."; Console.WriteLine(result);` — produces the identical output in one line instead of five. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++의 삼항 연산자와 문법이 동일**: `(condition) ? expressionTrue : expressionFalse` 문법이 C/C++와 차이가 없다는 점이 확인됨. [S1]
|
||||
- **바로 앞 챕터(else)의 예제를 그대로 재사용해 리팩터링으로 제시**: 새로운 예제를 만들지 않고 else 챕터의 time/greeting 코드를 그대로 가져와 5줄을 1줄로 줄이는 "before/after" 형태로 가르친다는 점이 확인됨 — 개념을 처음부터 다시 설명하지 않고 직전 학습 내용을 압축하는 방식. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
if...else 5줄짜리 시간대 인사말 코드를 삼항 연산자 한 줄로 압축하는 리팩터링 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Full if/else vs. ternary shorthand — same output (C#):
|
||||
```csharp
|
||||
// Full if/else (5 lines)
|
||||
int time = 20;
|
||||
if (time < 18) { Console.WriteLine("Good day."); }
|
||||
else { Console.WriteLine("Good evening."); }
|
||||
|
||||
// Ternary shorthand (1 line)
|
||||
string result = (time < 18) ? "Good day." : "Good evening.";
|
||||
Console.WriteLine(result);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Conditions ElseIf]], [[CSharp Switch]], [[CPP Conditions Shorthand]]
|
||||
- **참조 맥락:** Conditions 섹션의 마지막 챕터 — Switch 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Short Hand If...Else — https://www.w3schools.com/cs/cs_conditions_shorthand.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Short Hand If...Else" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user