docs(10_Wiki): Topic_Business/General/Graphic/Programming을 Topics/ 하위로 이동
최상위 10_Wiki/Topic_*였던 4개 카테고리 폴더를 10_Wiki/Topics/Topic_* 로 재배치. 콘텐츠 변경 없음(순수 폴더 이동) — Topics/ 하위 나머지 폴더는 이미 지난 커밋에서 전부 정리된 상태(잔존 항목은 에이전트 운영 상태 및 사용자가 보존을 요청한 업데이트0615/무제 3.canvas 뿐).
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
---
|
||||
id: csharp-tutorial-index
|
||||
title: "C# Tutorial"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["C# Tutorial", "C# MOC", "Topic_CSharp index", "C# 목차"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.90
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "moc", "index"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_intro.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[C# Tutorial]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Map of Content (MOC) for the W3Schools C# Tutorial — the root that links every core C# knowledge page in this topic folder. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- This folder (`Topic_CSharp`) wikifies the C# programming language tutorial, one knowledge page per document, in P-Reinforce v3.1 format — same convention as `Topic_CPP` / `Topic_C` / `Topic_Java` / `Topic_PHP` / `Topic_Python` / `Topic_SQL` / `Topic_W3CSS` / `Topic_HTML` / `Topic_CSS` / `Topic_JavaScript`. [S1]
|
||||
- **File prefix**: `CSharp_` (not `CS_`, to avoid ambiguity with "Computer Science"), folder `Topic_CSharp`. Source URL slugs use `cs_` and file extension `.php` (verified via curl, same as Topic_C — NOT `.asp` like Topic_CPP). [S1]
|
||||
- **Scope**: tutorial + "Learning by examples" pages only, scraped from `cs_intro.php`'s sidebar (58 links total, confirmed as the full & final list — no separate `default.php` exists for this category, 404). **Excluded**: `cs_compiler`/`cs_exam`/`cs_examples`/`cs_exercises`/`cs_practice`/`cs_quiz`/`cs_server`/`cs_study_plan`/`cs_syllabus` (meta/index pages), `cs_howto_add_two_numbers` (1 page, reserved for the separate HOW TO category later in the series). Notably, unlike other categories, no `cs_ref_*` reference-dump pages appeared in this sidebar at all. [S1]
|
||||
- **Progress:** **58 of 58 planned docs complete — C# category done.** [S1]
|
||||
- Every page roots its Knowledge Graph back to this `[[C# Tutorial]]` node.
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
|
||||
### Basics
|
||||
- [[CSharp Intro]] ✅
|
||||
- [[CSharp Get Started]] ✅
|
||||
- [[CSharp Syntax]] ✅
|
||||
- [[CSharp Output]] ✅
|
||||
- [[CSharp Comments]] ✅
|
||||
|
||||
### Variables
|
||||
- [[CSharp Variables]] ✅
|
||||
- [[CSharp Variables Identifiers]] ✅
|
||||
- [[CSharp Variables Constants]] ✅
|
||||
- [[CSharp Variables Display]] ✅
|
||||
- [[CSharp Variables Multiple]] ✅
|
||||
|
||||
### Data Types & Type Casting
|
||||
- [[CSharp Data Types]] ✅
|
||||
- [[CSharp Type Casting]] ✅
|
||||
|
||||
### Operators
|
||||
- [[CSharp Operators]] ✅
|
||||
- [[CSharp Operators Assignment]] ✅
|
||||
- [[CSharp Operators Comparison]] ✅
|
||||
- [[CSharp Operators Logical]] ✅
|
||||
|
||||
### Math
|
||||
- [[CSharp Math]] ✅
|
||||
|
||||
### Strings
|
||||
- [[CSharp Strings]] ✅
|
||||
- [[CSharp Strings Concat]] ✅
|
||||
- [[CSharp Strings Interpol]] ✅
|
||||
- [[CSharp Strings Access]] ✅
|
||||
- [[CSharp Strings Chars]] ✅
|
||||
|
||||
### Booleans
|
||||
- [[CSharp Booleans]] ✅
|
||||
|
||||
### Conditions
|
||||
- [[CSharp Conditions]] ✅
|
||||
- [[CSharp Conditions Else]] ✅
|
||||
- [[CSharp Conditions ElseIf]] ✅
|
||||
- [[CSharp Conditions Shorthand]] ✅
|
||||
|
||||
### Switch
|
||||
- [[CSharp Switch]] ✅
|
||||
|
||||
### Loops
|
||||
- [[CSharp While Loop]] ✅
|
||||
- [[CSharp For Loop]] ✅
|
||||
- [[CSharp Foreach Loop]] ✅
|
||||
- [[CSharp Break]] ✅
|
||||
|
||||
### Arrays
|
||||
- [[CSharp Arrays]] ✅
|
||||
- [[CSharp Arrays Loop]] ✅
|
||||
- [[CSharp Arrays Sort]] ✅
|
||||
- [[CSharp Arrays Multi]] ✅
|
||||
|
||||
### Methods
|
||||
- [[CSharp Methods]] ✅
|
||||
- [[CSharp Method Parameters]] ✅
|
||||
- [[CSharp Method Parameters Default]] ✅
|
||||
- [[CSharp Method Parameters Named Args]] ✅
|
||||
- [[CSharp Method Overloading]] ✅
|
||||
- [[CSharp Method Parameters Return]] ✅
|
||||
|
||||
### OOP Basics
|
||||
- [[CSharp OOP]] ✅
|
||||
- [[CSharp Classes]] ✅
|
||||
- [[CSharp Class Members]] ✅
|
||||
- [[CSharp Classes Multi]] ✅
|
||||
|
||||
### Constructors
|
||||
- [[CSharp Constructors]] ✅
|
||||
|
||||
### Access Modifiers & Properties
|
||||
- [[CSharp Access Modifiers]] ✅
|
||||
- [[CSharp Properties]] ✅
|
||||
|
||||
### Inheritance
|
||||
- [[CSharp Inheritance]] ✅
|
||||
|
||||
### Polymorphism & Abstract
|
||||
- [[CSharp Polymorphism]] ✅
|
||||
- [[CSharp Abstract]] ✅
|
||||
|
||||
### Interface
|
||||
- [[CSharp Interface]] ✅
|
||||
- [[CSharp Interface Multi]] ✅
|
||||
|
||||
### Enums
|
||||
- [[CSharp Enums]] ✅
|
||||
|
||||
### User Input
|
||||
- [[CSharp User Input]] ✅
|
||||
|
||||
### Exceptions
|
||||
- [[CSharp Exceptions]] ✅
|
||||
|
||||
### Files
|
||||
- [[CSharp Files]] ✅
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
58 knowledge documents generated across 21 sections in this batch run.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference)
|
||||
- **신뢰 점수:** 0.90
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[10_Wiki]]
|
||||
- **관련 개념:** [[C++ Tutorial]], [[Java Tutorial]], [[CSharp Intro]]
|
||||
- **참조 맥락:** SQL/Python/Java/PHP/W3.CSS/C/C++에 이어 W3Schools 지식화 시리즈의 다음 카테고리 — C++ 다음의 Microsoft/.NET 계열 객체지향 언어.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Tutorial — https://www.w3schools.com/cs/cs_intro.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Created C# Tutorial MOC with scope decisions and full planned page list (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
- 2026-07-04: Topic_CSharp completed — all 58 planned docs written across 21 sections (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
id: csharp-abstract
|
||||
title: "C# Abstraction"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["abstract class method C#", "C# 추상화"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "abstraction"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_abstract.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Abstraction]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Where C++ makes a class abstract IMPLICITLY (simply by containing at least one pure virtual function written as `virtual void f() = 0;`, with no dedicated "this class is abstract" keyword), C# makes it EXPLICIT with a dedicated `abstract` keyword on both the class AND each bodyless method (`abstract class Animal { public abstract void animalSound(); }`) — the same underlying restriction (cannot instantiate, must be inherited to be used, subclass MUST supply the missing method body) is enforced, but C# spells out the intent in the declaration itself rather than deriving it as a side-effect of the method's syntax. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Data abstraction** — hiding certain implementation details, showing only essential information to the user; achievable via abstract classes OR interfaces (interfaces deferred to the next chapter). [S1]
|
||||
- **`abstract` on a class** — creates a RESTRICTED class that cannot be used to instantiate objects directly (`new Animal()` on an abstract class is a compile error: "Cannot create an instance of the abstract class or interface"). [S1]
|
||||
- **`abstract` on a method** — declared with NO body (just a signature ending in `;`); only legal inside an abstract class; the body must be supplied by whichever derived class inherits it, using `override`. [S1]
|
||||
- **Mixed abstract classes** — an abstract class can freely combine abstract methods (no body) alongside regular, fully-implemented methods. [S1]
|
||||
- **Must be accessed via inheritance** — the ONLY way to use an abstract class's functionality is to inherit from it and instantiate the DERIVED class instead. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Illegal direct instantiation: `abstract class Animal { public abstract void animalSound(); public void sleep() { Console.WriteLine("Zzz"); } } ... Animal myObj = new Animal(); // Error`. [S1]
|
||||
- Full working example (Animal converted from the Polymorphism chapter into an abstract class): `abstract class Animal { public abstract void animalSound(); public void sleep() { Console.WriteLine("Zzz"); } } class Pig : Animal { public override void animalSound() { Console.WriteLine("The pig says: wee wee"); } } ... Pig myPig = new Pig(); myPig.animalSound(); myPig.sleep();` — the abstract method's body comes entirely from `Pig`, while `sleep()` (a regular method) is inherited unchanged. [S1]
|
||||
- Purpose stated directly: achieving security by hiding certain details and showing only the important parts of an object. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **abstract가 클래스에도 명시적 키워드로 붙음**: C++는 순수 가상 함수(`virtual void f() = 0;`) 하나만 있어도 클래스가 암묵적으로 추상 클래스가 되고 별도의 "추상 클래스" 키워드가 없었지만, C#은 클래스 자체에도 `abstract` 키워드를 명시적으로 붙여야 한다는 점이 확인됨 — 같은 제약(인스턴스화 불가, 상속 필수, 파생 클래스가 반드시 구현 제공)을 표현하는 방식이 암묵적(C++) vs 명시적(C#)으로 다름. [S1]
|
||||
- **Polymorphism 챕터의 Animal 예제가 그대로 재사용됨**: 새로운 예제를 만들지 않고 직전 Polymorphism 챕터의 Animal/Pig 예제를 abstract로 변환해 재사용한다는 점이 확인됨 — 개념을 처음부터 다시 설명하지 않고 이미 익힌 코드를 확장하는 방식. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
추상 메서드 animalSound()와 일반 메서드 sleep()을 함께 가진 abstract class Animal을 Pig가 상속해 animalSound()의 몸체만 제공하고 sleep()은 그대로 물려받아 쓰는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Abstract class mixing an abstract method (no body) and a regular method (C#):
|
||||
```csharp
|
||||
abstract class Animal
|
||||
{
|
||||
public abstract void animalSound(); // no body -- must be overridden
|
||||
public void sleep() // regular method -- inherited as-is
|
||||
{
|
||||
Console.WriteLine("Zzz");
|
||||
}
|
||||
}
|
||||
class Pig : Animal
|
||||
{
|
||||
public override void animalSound()
|
||||
{
|
||||
Console.WriteLine("The pig says: wee wee");
|
||||
}
|
||||
}
|
||||
|
||||
Pig myPig = new Pig();
|
||||
myPig.animalSound(); // "The pig says: wee wee"
|
||||
myPig.sleep(); // "Zzz"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Polymorphism]], [[CSharp Interface]], [[CPP Templates]]
|
||||
- **참조 맥락:** Polymorphism & Abstract 섹션의 마지막 챕터 — Interface 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Abstraction — https://www.w3schools.com/cs/cs_abstract.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Abstraction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,83 @@
|
||||
---
|
||||
id: csharp-access-modifiers
|
||||
title: "C# Access Modifiers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["public private protected internal C#", "C# 접근 제한자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "access-modifiers"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_access_modifiers.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Access Modifiers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# adds a FOURTH access level — `internal` (accessible within the same assembly, not across assemblies) — that has no direct C++ equivalent, since "assembly" is a .NET-specific compiled-unit concept C++'s translation-unit/library model doesn't share; meanwhile `public`/`private`/`protected` carry the same meanings as C++, and the default-to-`private`-when-unspecified rule for class members is IDENTICAL to what Topic_CPP already confirmed for C++ classes — making `internal` (plus the two combinations `protected internal` and `private protected`, mentioned but deferred) the one genuinely new addition in this chapter. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`public`** — accessible from ALL classes. [S1]
|
||||
- **`private`** — accessible ONLY within the same class. [S1]
|
||||
- **`protected`** — accessible within the same class OR classes that inherit from it (full detail deferred to Inheritance). [S1]
|
||||
- **`internal`** — accessible only within its own ASSEMBLY, not from another assembly (detail deferred; no equivalent concept in C/C++ covered so far in this series). [S1]
|
||||
- **Combined modifiers** — `protected internal` and `private protected` exist but aren't covered in depth here. [S1]
|
||||
- **Default access = private** — if no access modifier is specified on a class member, it defaults to `private`. [S1]
|
||||
- **Purpose** — controls visibility/security of class members, and enables Encapsulation (hiding sensitive data by making fields private, deferred to the next chapter). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Private field, accessed from WITHIN its own class: works fine, prints `"Mustang"`. [S1]
|
||||
- Private field, accessed from a DIFFERENT class (`Program`): compile error — `'Car.model' is inaccessible due to its protection level`. [S1]
|
||||
- Public field, accessed from a different class: works, prints `"Mustang"`. [S1]
|
||||
- Implicit private default: `class Car { string model; string year; }` — both fields are private even though no keyword is written. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **기본 접근 수준(private)은 C++와 동일**: 접근 제한자를 명시하지 않으면 private가 기본값이라는 규칙이 Topic_CPP의 Access Specifiers 챕터에서 확인된 규칙과 차이가 없다는 점이 확인됨. [S1]
|
||||
- **internal은 C/C++에 대응 개념이 없는 새로운 접근 수준**: "같은 어셈블리 내에서만 접근 가능, 다른 어셈블리에서는 불가"라는 internal의 정의는 .NET의 컴파일 단위인 어셈블리 개념에 의존하며, 이 시리즈의 C/C++ 챕터에는 대응하는 개념이 없었다는 점이 새로운 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
private 필드를 같은 클래스 안에서 접근할 때는 성공하고, 다른 클래스(Program)에서 접근하면 컴파일 에러가 나는 것을 대비해 보여주는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
private field inaccessible from another class — compile error (C#):
|
||||
```csharp
|
||||
class Car
|
||||
{
|
||||
private string model = "Mustang";
|
||||
}
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Car myObj = new Car();
|
||||
Console.WriteLine(myObj.model);
|
||||
// Error: 'Car.model' is inaccessible due to its protection level
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Constructors]], [[CSharp Properties]], [[CPP Access Specifiers]]
|
||||
- **참조 맥락:** Access Modifiers & Properties 섹션 — Properties (Get and Set) 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Access Modifiers — https://www.w3schools.com/cs/cs_access_modifiers.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Access Modifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: csharp-arrays
|
||||
title: "C# Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["array declaration C#", "new keyword arrays", "C# 배열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "arrays"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_arrays.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s array declaration puts the brackets right after the TYPE (`string[] cars;`), not after the variable name like C's `char cars[4];` — a real syntactic divergence hiding under superficial similarity, and the tutorial explicitly documents FOUR equivalent ways to construct the same array (bare braces, `new type[size]`, `new type[size] {...}`, `new type[] {...}`), while also stating a hard rule the C family never needed: if you declare an array first and assign its values LATER (in a separate statement), the `new` keyword becomes MANDATORY — omitting it is a compile error, unlike C where separate declaration and initialization of an array is simply not possible with a brace list at all. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Declaration syntax** — `type[] variableName;` — brackets attach to the TYPE, not the variable name (contrast with C's `type variableName[size];`). [S1]
|
||||
- **Array literal** — `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};` — values in a comma-separated, brace-wrapped list. [S1]
|
||||
- **Index access, 0-based** — `cars[0]` is the first element, same convention as every prior language in this series. [S1]
|
||||
- **Mutable elements** — `cars[0] = "Opel";` overwrites an existing element directly. [S1]
|
||||
- **`.Length` property** — no parentheses, matching the string `.Length` property's design (property, not method). [S1]
|
||||
- **Four equivalent construction forms**: `new string[4]` (empty, size 4), `new string[4] {...}` (size + values), `new string[] {...}` (values, size inferred), and bare `{...}` (values, size inferred, no `new`). [S1]
|
||||
- **`new` becomes mandatory when assigning after declaration** — `string[] cars; cars = new string[] {"Volvo", "BMW", "Ford"};` works, but `cars = {"Volvo", "BMW", "Ford"};` (without `new`) is a compile error. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Access: `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; Console.WriteLine(cars[0]); // Volvo`. [S1]
|
||||
- Modify: `cars[0] = "Opel"; Console.WriteLine(cars[0]); // Opel`. [S1]
|
||||
- Length: `Console.WriteLine(cars.Length); // 4`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **대괄호가 변수명이 아니라 타입에 붙음**: C의 배열 선언은 `char cars[4];`처럼 대괄호가 변수명 뒤에 붙었지만, C#은 `string[] cars;`처럼 타입 바로 뒤에 대괄호가 붙는다는 점이 확인됨 — 표면적으로 비슷해 보이지만 실제 문법 위치가 다름. [S1]
|
||||
- **선언 후 대입 시 new가 필수가 됨**: 선언과 초기화를 분리할 경우(`string[] cars;` 이후 `cars = {...};`) 중괄호만으로는 컴파일 에러가 나고 반드시 `new string[] {...}`처럼 new를 붙여야 한다는 규칙이 확인됨 — C는애초에 배열을 선언 후 별도 문장에서 중괄호 리스트로 재할당하는 것 자체가 불가능하므로 C에는 없던 규칙. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
자동차 이름 배열을 선언하고, 첫 원소를 읽고 바꾸고, 길이를 확인하는 기본 흐름이 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Four equivalent array construction forms, and the mandatory `new` on later assignment (C#):
|
||||
```csharp
|
||||
string[] cars1 = new string[4]; // empty, size 4
|
||||
string[] cars2 = new string[4] {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
string[] cars3 = new string[] {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
string[] cars4 = {"Volvo", "BMW", "Ford", "Mazda"}; // no `new` needed here
|
||||
|
||||
string[] cars5;
|
||||
cars5 = new string[] {"Volvo", "BMW", "Ford"}; // new REQUIRED when assigned separately
|
||||
// cars5 = {"Volvo", "BMW", "Ford"}; // error without new
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Break]], [[CSharp Arrays Loop]], [[C Arrays]], [[CPP Arrays]]
|
||||
- **참조 맥락:** Arrays 섹션 — Loop Through Arrays 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Arrays — https://www.w3schools.com/cs/cs_arrays.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: csharp-arrays-loop
|
||||
title: "C# Loop Through Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["for loop array C#", "foreach array 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", "arrays", "loops"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_arrays_loop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Arrays Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter directly recycles the exact `foreach` example already shown in the Loops section's Foreach chapter — same `cars` array, same code — but now frames it explicitly AGAINST the indexed `for` loop alternative, making an explicit value judgment the earlier chapter didn't state outright: `foreach` is "easier to write... does not require a counter... more readable," a direct trade-off statement this wiki hasn't seen phrased this bluntly for C or C++'s equivalent range-based loops. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Indexed `for` loop over an array** — uses `.Length` as the loop bound: `for (int i = 0; i < cars.Length; i++) { Console.WriteLine(cars[i]); }`. [S1]
|
||||
- **`foreach` loop over an array** — no counter, no `.Length`, no index: `foreach (string i in cars) { Console.WriteLine(i); }`. [S1]
|
||||
- **Explicit trade-off stated** — `foreach` is easier to write, doesn't need a counter, and is more readable than the indexed `for` — a direct recommendation, not just a neutral alternative. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Indexed loop: `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; for (int i = 0; i < cars.Length; i++) { Console.WriteLine(cars[i]); }`. [S1]
|
||||
- Foreach loop (identical to the earlier Foreach Loop chapter's own example): `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; foreach (string i in cars) { Console.WriteLine(i); }`. [S1]
|
||||
- Reading aid: "for each string element (called i — as in index) in cars, print out the value of i." [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **foreach가 for보다 명시적으로 권장됨**: 이전 Foreach Loop 챕터는 foreach를 단순히 소개만 했지만, 이번 챕터는 for와 나란히 비교하며 "카운터가 필요 없고 더 읽기 쉽다"고 명시적으로 우위를 선언한다는 점이 확인됨 — 두 방식이 동등한 대안이 아니라 foreach가 권장되는 선택임을 분명히 함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
동일한 자동차 이름 배열을 인덱스 기반 for 루프와 foreach 루프 두 가지로 순회해 비교하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Indexed for loop vs. foreach — same output, different readability (C#):
|
||||
```csharp
|
||||
string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
|
||||
for (int i = 0; i < cars.Length; i++)
|
||||
{
|
||||
Console.WriteLine(cars[i]);
|
||||
}
|
||||
|
||||
foreach (string i in cars)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Arrays]], [[CSharp Arrays Sort]], [[CSharp Foreach Loop]]
|
||||
- **참조 맥락:** Arrays 섹션 — Sort Arrays 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Loop Through Arrays — https://www.w3schools.com/cs/cs_arrays_loop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Loop Through Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: csharp-arrays-multi
|
||||
title: "C# Multidimensional Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["2D array C#", "GetLength()", "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", "arrays", "multidimensional"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_arrays_multi.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Multidimensional Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s true 2D array uses ONE bracket pair with an internal comma (`int[,] numbers`), fundamentally different from C's stacked-bracket 2D array (`int numbers[2][3]`, effectively an array of arrays) — and this single-object design is why C# needs a NEW method, `GetLength(dimension)`, instead of reusing `.Length` (which on a 2D array would only report the total flattened element count, not a per-dimension size), forcing a second, dimension-aware sizing API that C's simpler nested-array model never required. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`int[,] name = { {...}, {...} };`** — a single comma inside one bracket pair signals a 2D array; two commas (`[,,]`) would signal 3D. [S1]
|
||||
- **Row/column indexing** — `numbers[row, col]` — a SINGLE index expression with two comma-separated values, not `numbers[row][col]` (double bracket, as in C's array-of-arrays model). [S1]
|
||||
- **Element access & mutation** — `numbers[0, 2]` reads row 0, column 2; `numbers[0, 0] = 5;` writes to row 0, column 0. [S1]
|
||||
- **`foreach` over a 2D array** — flattens automatically: `foreach (int i in numbers)` visits every element across all rows without needing nested loops. [S1]
|
||||
- **`GetLength(dimension)`** — replaces `.Length` for multidimensional sizing; `GetLength(0)` returns the row count, `GetLength(1)` returns the column count — one loop bound per dimension. [S1]
|
||||
- **Nested `for` loop required for row/column-aware iteration** — one loop per dimension, using `GetLength(0)` and `GetLength(1)` as the respective bounds. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration: `int[,] numbers = { {1, 4, 2}, {3, 6, 8} };` — two "rows," each with three "columns." [S1]
|
||||
- Access: `Console.WriteLine(numbers[0, 2]); // 2` (row 0, column 2). [S1]
|
||||
- Modify: `numbers[0, 0] = 5; Console.WriteLine(numbers[0, 0]); // 5`. [S1]
|
||||
- Flattened foreach: `foreach (int i in numbers) { Console.WriteLine(i); }` — prints all 6 elements in row-major order. [S1]
|
||||
- Dimension-aware nested for: `for (int i = 0; i < numbers.GetLength(0); i++) { for (int j = 0; j < numbers.GetLength(1); j++) { Console.WriteLine(numbers[i, j]); } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C의 배열의 배열 모델과 근본적으로 다른 단일 객체 설계**: C의 2D 배열(`int numbers[2][3]`)은 사실상 배열의 배열이라 `numbers[i][j]`처럼 대괄호를 두 번 쓰지만, C#의 `int[,] numbers`는 콤마로 차원을 표시하는 단일 객체이며 `numbers[i, j]`처럼 하나의 인덱스 표현식 안에 콤마로 두 값을 전달한다는 점이 확인됨. [S1]
|
||||
- **Length 대신 GetLength(dimension)이 필요해짐**: 1차원 배열의 `.Length` 프로퍼티는 다차원 배열에서는 차원별 크기를 알려주지 못하므로, C#은 `GetLength(0)`/`GetLength(1)`처럼 차원 인덱스를 받는 별도 메서드를 도입했다는 점이 새로운 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
2행 3열의 정수 2D 배열을 선언하고, 특정 원소를 읽고/바꾸고, foreach와 이중 for 루프(GetLength 사용) 두 가지 방식으로 순회하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
2D array — single bracket + comma indexing, GetLength() for dimension-aware loops (C#):
|
||||
```csharp
|
||||
int[,] numbers = { {1, 4, 2}, {3, 6, 8} };
|
||||
Console.WriteLine(numbers[0, 2]); // 2 (row 0, col 2)
|
||||
|
||||
for (int i = 0; i < numbers.GetLength(0); i++) // rows
|
||||
{
|
||||
for (int j = 0; j < numbers.GetLength(1); j++) // columns
|
||||
{
|
||||
Console.WriteLine(numbers[i, j]);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Arrays Sort]], [[CSharp Methods]], [[C Arrays]]
|
||||
- **참조 맥락:** Arrays 섹션의 마지막 챕터 — Methods 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Multidimensional Arrays — https://www.w3schools.com/cs/cs_arrays_multi.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Multidimensional Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
id: csharp-arrays-sort
|
||||
title: "C# Sort Arrays"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Array.Sort", "System.Linq Max Min Sum", "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", "arrays", "sort", "linq"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_arrays_sort.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Sort Arrays]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`Array.Sort(cars)` mirrors C++'s `sort()` from `<algorithm>` in spirit (both sort in place, ascending by default, work for strings and numbers alike) — but C#'s aggregate helpers (`myNumbers.Max()`, `.Min()`, `.Sum()`) come from a SEPARATE namespace (`System.Linq`) that must be explicitly imported with its own `using` statement, meaning basic sorting is a core language feature (`Array.Sort`) while summary statistics are an OPT-IN library extension — a modularity split C++'s `<algorithm>` (which bundles `sort()`, `min_element()`, `max_element()` all in one header) doesn't make. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`Array.Sort(arrayName)`** — sorts an array in place, alphabetically for strings or ascending for numbers; static method on the `Array` class. [S1]
|
||||
- **`System.Linq` namespace** — must be explicitly imported (`using System.Linq;`) to unlock extension methods like `.Max()`, `.Min()`, `.Sum()` directly on array instances. [S1]
|
||||
- **`.Max()` / `.Min()` / `.Sum()`** — instance-style method calls on the array itself (`myNumbers.Max()`), not static calls through a class name like `Array.Sort()`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- String sort: `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; Array.Sort(cars); foreach (string i in cars) { Console.WriteLine(i); }` → alphabetical order. [S1]
|
||||
- Int sort: `int[] myNumbers = {5, 1, 8, 9}; Array.Sort(myNumbers); foreach (int i in myNumbers) { Console.WriteLine(i); }` → ascending order. [S1]
|
||||
- LINQ aggregates (requires `using System.Linq;` at the top of the file): `int[] myNumbers = {5, 1, 8, 9}; Console.WriteLine(myNumbers.Max()); Console.WriteLine(myNumbers.Min()); Console.WriteLine(myNumbers.Sum());` → 9, 1, 23. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **정렬은 핵심 기능, 집계 함수는 별도 네임스페이스 opt-in**: C++의 `<algorithm>`은 sort()/min_element()/max_element()를 한 헤더에 모두 묶어 제공했지만, C#은 `Array.Sort()`는 기본으로 쓸 수 있는 반면 Max()/Min()/Sum()은 `System.Linq`라는 별도 네임스페이스를 명시적으로 import해야만 쓸 수 있다는 점이 확인됨 — 기능 모듈화 방식이 C++와 다름. [S1]
|
||||
- **호출 방식도 다름**: `Array.Sort(cars)`는 클래스 이름을 통한 정적 호출이지만, `myNumbers.Max()`는 배열 인스턴스 자체에 점(.)으로 붙는 확장 메서드 호출이라는 점에서 스타일이 다름. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
문자열 배열과 정수 배열을 각각 Array.Sort()로 정렬하고, System.Linq를 import해 Max/Min/Sum을 구하는 두 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Array.Sort() vs. System.Linq aggregate methods — different import requirements (C#):
|
||||
```csharp
|
||||
using System;
|
||||
using System.Linq; // required for Max/Min/Sum
|
||||
|
||||
int[] myNumbers = {5, 1, 8, 9};
|
||||
Array.Sort(myNumbers); // core feature, no extra using needed
|
||||
Console.WriteLine(myNumbers.Max()); // 9 -- requires System.Linq
|
||||
Console.WriteLine(myNumbers.Min()); // 1
|
||||
Console.WriteLine(myNumbers.Sum()); // 23
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Arrays Loop]], [[CSharp Arrays Multi]], [[CPP Algorithms]]
|
||||
- **참조 맥락:** Arrays 섹션의 마지막 챕터 — Multidimensional Arrays 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Sort Arrays — https://www.w3schools.com/cs/cs_arrays_sort.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Sort Arrays" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
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).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: csharp-break
|
||||
title: "C# Break and Continue"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["break continue C#", "C# break continue"]
|
||||
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", "loops", "break", "continue"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_break.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[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#):
|
||||
```csharp
|
||||
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)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Foreach Loop]], [[CSharp Switch]], [[CSharp Arrays]], [[CPP Break]]
|
||||
- **참조 맥락:** Loops 섹션의 마지막 챕터 — Arrays 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Break and Continue — https://www.w3schools.com/cs/cs_break.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Break and Continue" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: csharp-class-members
|
||||
title: "C# Class Members"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["fields and methods C#", "public vs static C#", "C# 클래스 멤버"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "class-members"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_class_members.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Class Members]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter directly answers a question it poses itself — "why public, not static, like in the Methods chapter?" — with a crisp rule: `static` methods belong to the CLASS and need no object, while `public` methods belong to OBJECTS and can only be called through an instance; this reframes everything the Methods section taught (`static void MyMethod()`) as having been INCOMPLETE for real OOP use, since every method there was callable without ever creating an object — a limitation this chapter's Car/fullThrottle() example exists specifically to break. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Class members** — fields and methods declared inside a class, collectively. [S1]
|
||||
- **Fields** — variables inside a class; accessed via an object using dot syntax (`myObj.color`), can be assigned a default value inline or left blank and set later via the object. [S1]
|
||||
- **`static` vs. `public` methods** — `static` methods are callable WITHOUT creating an object (belong to the class); `public` methods require an object instance to call (belong to objects) — this is why object methods use `public`, not `static`. [S1]
|
||||
- **Method access via dot syntax** — `myObj.fullThrottle();`, same pattern as field access. [S1]
|
||||
- **Multiple objects, independent field values** — creating several objects of the same class (`Car Ford`, `Car Opel`) gives each its own independent copy of the fields. [S1]
|
||||
- **Multiple classes for organization** — one class (e.g. `Car`) holds fields/methods, another (e.g. `Program`) holds `Main()` and does the work; recommended practice. [S1]
|
||||
- **`public` as access modifier** — when fields need to be accessible from ANOTHER class (like `Program` accessing `Car`'s fields), those fields must be marked `public`; deferred full coverage to a later Access Modifiers chapter. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Field-only access: `class Car { string color = "red"; int maxSpeed = 200; static void Main(string[] args) { Car myObj = new Car(); Console.WriteLine(myObj.color); Console.WriteLine(myObj.maxSpeed); } }`. [S1]
|
||||
- Blank fields set via object: `string color; int maxSpeed; ... myObj.color = "red"; myObj.maxSpeed = 200;`. [S1]
|
||||
- Multiple independent objects: `Car Ford = new Car(); Ford.model = "Mustang"; ... Car Opel = new Car(); Opel.model = "Astra"; ...` — each object's fields are independent. [S1]
|
||||
- Object method call requiring `public`: `public void fullThrottle() { Console.WriteLine("The car is going as fast as it can!"); } ... myObj.fullThrottle();`. [S1]
|
||||
- Cross-class access with `public` fields: a `Car` class in one file exposes `public string model;` etc., and a separate `Program` class's `Main()` creates/uses `Car` objects. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Methods 챕터의 static이 실제로는 제약이었음이 드러남**: Methods 챕터에서 배운 `static void MyMethod()`는 객체 생성 없이 클래스명만으로 호출 가능한 방식이었는데, 이번 챕터는 이것이 진짜 OOP의 "객체 메서드"와는 다른 것이며, 객체를 통해 호출하는 메서드는 반드시 `public`(static이 아님)이어야 한다는 점을 명확히 함 — Methods 챕터의 모든 예제가 사실 객체 없이도 동작하는 방식이었다는 한계가 이번 챕터에서 드러남. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Ford와 Opel 두 Car 객체를 만들어 각각 다른 model/color/year 값을 독립적으로 저장하고, fullThrottle() 메서드를 public으로 선언해 객체를 통해 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
static (class-level, no object needed) vs. public (object-level, requires an instance) methods (C#):
|
||||
```csharp
|
||||
class Car
|
||||
{
|
||||
public string model;
|
||||
public void fullThrottle() // public -- called through an object
|
||||
{
|
||||
Console.WriteLine("The car is going as fast as it can!");
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args) // static -- belongs to the class itself
|
||||
{
|
||||
Car myObj = new Car();
|
||||
myObj.fullThrottle(); // requires the object instance
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Classes]], [[CSharp Classes Multi]], [[CSharp Methods]], [[CSharp Access Modifiers]]
|
||||
- **참조 맥락:** OOP Basics 섹션 — Multiple Classes and Objects 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Class Members — https://www.w3schools.com/cs/cs_class_members.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Class Members" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,76 @@
|
||||
---
|
||||
id: csharp-classes
|
||||
title: "C# Classes and Objects"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["new keyword objects C#", "field C#", "C# 클래스와 객체"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "classes"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_classes.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Classes]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The chapter's own explicit aside — "it is common that the name of the C# file and the class matches... However it is not required (like in Java)" — directly repeats the exact comparison already flagged in the Syntax chapter, meaning W3Schools' C# tutorial itself considers this Java contrast important enough to state TWICE across the series; the object-creation syntax `Car myObj = new Car();` is otherwise structurally identical to C++'s heap-allocation `new` (though C# never requires a matching `delete` — memory is garbage-collected, a fact not yet stated in this chapter but implied by its complete absence). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`class` keyword** — defines a class, e.g. `class Car { string color = "red"; }`. [S1]
|
||||
- **Field** — a variable declared directly inside a class; also called an "attribute". [S1]
|
||||
- **Naming convention (again)** — class names should start uppercase (good practice, not enforced); file name matching class name is common but, unlike Java, NOT required. [S1]
|
||||
- **Object creation** — `ClassName objectName = new ClassName();`, e.g. `Car myObj = new Car();`. [S1]
|
||||
- **Dot syntax** — `myObj.color` accesses a field on an object instance. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Class with a field: `class Car { string color = "red"; }`. [S1]
|
||||
- Full object creation + field access example: `class Car { string color = "red"; static void Main(string[] args) { Car myObj = new Car(); Console.WriteLine(myObj.color); } }` → outputs `"red"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Java와의 파일명 대비가 시리즈에서 두 번째로 반복됨**: Syntax 챕터에서 이미 "C#은 Java와 달리 파일명과 클래스명이 일치할 필요가 없다"고 언급했는데, 이번 Classes 챕터가 동일한 비교를 다시 명시적으로 반복한다는 점이 확인됨 — W3Schools가 이 차이를 중요하게 여겨 두 번 강조. [S1]
|
||||
- **new 키워드는 C++와 문법이 같지만 delete 짝이 없음**: `new Car()`가 C++의 힙 할당 `new`와 문법상 동일해 보이지만, 이 챕터(그리고 이후 챕터들)에서 `delete`에 대응하는 언급이 전혀 등장하지 않는다는 점이 확인됨 — C#의 가비지 컬렉션 기반 메모리 관리를 암시(다만 이 챕터가 명시적으로 설명하지는 않음). [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Car 클래스에 color 필드를 정의하고, new로 객체를 만들어 점(.) 문법으로 필드 값을 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Class definition, object creation, and dot-syntax field access (C#):
|
||||
```csharp
|
||||
class Car
|
||||
{
|
||||
string color = "red";
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Car myObj = new Car();
|
||||
Console.WriteLine(myObj.color); // "red"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp OOP]], [[CSharp Class Members]], [[CSharp Syntax]], [[CPP Classes]]
|
||||
- **참조 맥락:** OOP Basics 섹션 — Class Members 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Classes and Objects — https://www.w3schools.com/cs/cs_classes.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Classes and Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: csharp-classes-multi
|
||||
title: "C# Multiple Classes and Objects"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["multiple objects same class C#", "separate files classes 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", "oop", "classes"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_classes_multi.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Multiple Classes and Objects]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This short chapter is largely a distilled repeat of patterns already shown in Class Members (multiple objects of one class, splitting fields/methods into one class and `Main()` into another) — its only genuinely new emphasis is calling out the `public` keyword by its formal name, "access modifier," and stating outright that without it, a field defined in one class (`Car`) would NOT be reachable from another class (`Program`), making the two-file `prog2.cs`/`prog.cs` split only work BECAUSE of that modifier. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Multiple objects of one class** — `Car myObj1 = new Car(); Car myObj2 = new Car();` — each is an independent instance. [S1]
|
||||
- **Splitting classes across files** — one class (fields/methods) in one file (`prog2.cs`), another class (with `Main()`) in a separate file (`prog.cs`) — recommended for organization. [S1]
|
||||
- **`public` = access modifier** — explicitly named as such here; it's what makes a field defined in `Car` reachable from the unrelated `Program` class. Without `public`, cross-class access would fail. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Two objects, same class: `class Car { string color = "red"; static void Main(string[] args) { Car myObj1 = new Car(); Car myObj2 = new Car(); Console.WriteLine(myObj1.color); Console.WriteLine(myObj2.color); } }`. [S1]
|
||||
- Cross-file class + access: `prog2.cs`: `class Car { public string color = "red"; }`; `prog.cs`: `class Program { static void Main(string[] args) { Car myObj = new Car(); Console.WriteLine(myObj.color); } }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **public이 "접근 제한자(access modifier)"라는 공식 용어로 명명됨**: Class Members 챕터에서는 public을 별도 이름 없이 사용했지만, 이번 챕터는 이를 명시적으로 "access modifier"라고 부르며 이것이 없으면 다른 클래스에서 필드에 접근할 수 없다는 점을 재확인함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
동일한 Car 클래스로 두 개의 독립된 객체를 만드는 예제와, Car와 Program을 서로 다른 파일로 분리하되 public으로 필드를 노출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Cross-class field access requires `public` (the access modifier) (C#):
|
||||
```csharp
|
||||
// prog2.cs
|
||||
class Car
|
||||
{
|
||||
public string color = "red"; // public required for cross-class access
|
||||
}
|
||||
|
||||
// prog.cs
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Car myObj = new Car();
|
||||
Console.WriteLine(myObj.color);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Class Members]], [[CSharp Constructors]], [[CSharp Access Modifiers]]
|
||||
- **참조 맥락:** OOP Basics 섹션의 마지막 챕터 — Constructors 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Multiple Classes and Objects — https://www.w3schools.com/cs/cs_classes_multi.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Multiple Classes and Objects" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: csharp-comments
|
||||
title: "C# Comments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["single-line comments C#", "multi-line comments C#", "C# 주석"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "comments"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_comments.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Comments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s comment syntax (`//` single-line, `/* */` multi-line) is byte-for-byte identical to C, C++, and Java's — the FIRST chapter in this entire C# series where the answer to "how is this different from what I already know" is simply "it isn't," confirming the Intro chapter's claim of syntactic closeness to the C family in the most literal, zero-abstraction way possible. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Single-line comments (`//`)** — everything from `//` to the end of the line is ignored; usable on its own line before code or appended at the end of a code line. [S1]
|
||||
- **Multi-line comments (`/* ... */`)** — everything between the markers is ignored, regardless of how many lines it spans. [S1]
|
||||
- **Convention** — `//` for short comments, `/* */` for longer explanatory blocks; purely a style choice. [S1]
|
||||
- **Purpose** — explain code for readability, or temporarily disable code during testing. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Before-line comment: `// This is a comment` followed by `Console.WriteLine("Hello World!");`. [S1]
|
||||
- End-of-line comment: `Console.WriteLine("Hello World!"); // This is a comment`. [S1]
|
||||
- Multi-line block: `/* The code below will print the words Hello World to the screen, and it is amazing */` followed by the print statement. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++/Java와 완전히 동일한 주석 문법**: `//`와 `/* */` 문법이 C, C++, Java와 토씨 하나 다르지 않게 동일하다는 점이 확인됨 — Intro 챕터가 주장한 "C 계열과 문법이 가깝다"는 서술이 이번 챕터에서는 차이 없이 그대로 성립하는 첫 사례. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 줄 앞/뒤 단일행 주석과 여러 줄 블록 주석 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Single-line and multi-line comments — identical syntax to C/C++/Java (C#):
|
||||
```csharp
|
||||
// This is a comment
|
||||
Console.WriteLine("Hello World!"); // This is a comment
|
||||
|
||||
/* The code below will print the words Hello World
|
||||
to the screen, and it is amazing */
|
||||
Console.WriteLine("Hello World!");
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Output]], [[CSharp Variables]], [[CPP Comments]]
|
||||
- **참조 맥락:** Basics 섹션의 마지막 챕터 — Variables 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Comments — https://www.w3schools.com/cs/cs_comments.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Comments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: csharp-conditions
|
||||
title: "C# If ... Else"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["if statement 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", "conditions", "if"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_conditions.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Conditions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `if (condition) { ... }` syntax is byte-identical to C/C++/Java, and the chapter's own explicit warning — "if is in lowercase letters; If or IF will generate an error" — is the same case-sensitivity rule already established in the Identifiers chapter, now applied to KEYWORDS rather than variable names, closing the loop on C#'s case-sensitivity being a blanket rule across the entire language (identifiers AND keywords), not just a variable-naming quirk. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comparison conditions inherited from math** — `<`, `<=`, `>`, `>=`, `==`, `!=`, already covered in the Comparison Operators chapter, are the building blocks of every condition. [S1]
|
||||
- **Four conditional constructs previewed** — `if` (execute if true), `else` (execute if false), `else if` (test a new condition if the first was false), `switch` (many alternative blocks). [S1]
|
||||
- **`if` syntax**: `if (condition) { // code }` — code inside the braces runs only when `condition` evaluates to `True`. [S1]
|
||||
- **Case-sensitivity applies to keywords, not just identifiers** — `If` or `IF` (capitalized) is a compile error; only lowercase `if` is valid. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Literal condition: `if (20 > 18) { Console.WriteLine("20 is greater than 18"); }`. [S1]
|
||||
- Variable condition: `int x = 20; int y = 18; if (x > y) { Console.WriteLine("x is greater than y"); }`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **대소문자 구분이 키워드에도 적용됨을 명시적으로 확인**: Identifiers 챕터에서 변수명의 대소문자 구분(`myVar` vs `myvar`)을 배웠는데, 이번 챕터는 `if`라는 키워드 자체도 대문자로 쓰면(`If`, `IF`) 에러가 난다고 명시 — 대소문자 구분이 식별자뿐 아니라 언어 전체(키워드 포함)에 적용되는 규칙임이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 리터럴 비교(20 > 18)와 변수 비교(x > y) 두 가지 if 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Basic if statement — lowercase `if` only (C#):
|
||||
```csharp
|
||||
int x = 20;
|
||||
int y = 18;
|
||||
if (x > y)
|
||||
{
|
||||
Console.WriteLine("x is greater than y");
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Booleans]], [[CSharp Conditions Else]], [[CPP Conditions]]
|
||||
- **참조 맥락:** Conditions 섹션 — The else Statement 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# If ... Else — https://www.w3schools.com/cs/cs_conditions.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# If ... Else" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: csharp-conditions-else
|
||||
title: "C# The else Statement"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["else statement C#", "C# else 문"]
|
||||
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", "else"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_conditions_else.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Conditions Else]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This is the exact same `if (time >= votingAge) {...} else {...}` pattern already demonstrated in the Booleans chapter's voting example — the tutorial reuses the identical time/greeting scenario here with formal syntax framing, confirming this series deliberately teaches a concept informally (Booleans) before returning to name and formalize it (Conditions), rather than introducing each construct exactly once. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`else`** — specifies a block of code to execute when the `if` condition is `False`. [S1]
|
||||
- **Syntax**: `if (condition) { // True branch } else { // False branch }` — exactly one of the two blocks ever executes. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example: `int time = 20; if (time < 18) { Console.WriteLine("Good day."); } else { Console.WriteLine("Good evening."); }` → since `20` is NOT less than `18`, the condition is False, so the `else` branch runs, printing `"Good evening."`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Booleans 챕터의 예제 패턴이 그대로 재사용됨**: Booleans 챕터에서 이미 투표 연령 예제로 if/else를 미리 보여줬는데, 이번 챕터는 시간대(time) 인사말이라는 다른 소재지만 동일한 "if 조건 → else 대안" 구조를 공식 문법 설명과 함께 다시 제시한다는 점이 확인됨 — 이 시리즈는 개념을 비공식적으로 먼저 보여준 뒤(Booleans) 나중에 공식적으로 명명·설명(Conditions)하는 방식을 취함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 시각(time=20)이 18보다 작은지 확인해 "Good day."/"Good evening."을 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
if/else — exactly one branch executes (C#):
|
||||
```csharp
|
||||
int time = 20;
|
||||
if (time < 18)
|
||||
{
|
||||
Console.WriteLine("Good day.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Good evening.");
|
||||
}
|
||||
// Outputs "Good evening."
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Conditions]], [[CSharp Conditions ElseIf]], [[CSharp Booleans]]
|
||||
- **참조 맥락:** Conditions 섹션 — The else if Statement 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# The else Statement — https://www.w3schools.com/cs/cs_conditions_else.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# The else Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: csharp-conditions-elseif
|
||||
title: "C# The else if Statement"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["else if statement C#", "C# else if 문"]
|
||||
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", "elseif"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_conditions_elseif.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Conditions ElseIf]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`else if` is not a distinct keyword in C# any more than in C/C++/Java — it's just an `else` block whose body happens to be another `if` statement, which the three-way morning/day/evening example makes visible: each additional `else if` is really nested inside the previous `else`, and the chain only terminates in a plain `else` when every prior condition has failed, evaluated strictly top-to-bottom with short-circuit stopping at the first true condition. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`else if`** — tests a NEW condition only when all prior conditions in the chain were false. [S1]
|
||||
- **Syntax**: `if (condition1) {...} else if (condition2) {...} else {...}` — any number of `else if` blocks can be chained between the initial `if` and the final `else`. [S1]
|
||||
- **Top-to-bottom, first-match evaluation** — conditions are checked in order; the first one that's true runs its block and the rest of the chain is skipped entirely. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Three-branch time-of-day example: `int time = 22; if (time < 10) { Console.WriteLine("Good morning."); } else if (time < 20) { Console.WriteLine("Good day."); } else { Console.WriteLine("Good evening."); }` — since `22` is not `< 10` (condition1 false) and not `< 20` (condition2 also false), execution falls through to the final `else`, printing `"Good evening."`. [S1]
|
||||
- The tutorial notes that if `time` were `14` instead, the program would print `"Good day."` (condition2 would be true). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **else if는 별도 키워드가 아니라 else의 본문이 if인 구조**: C/C++/Java와 마찬가지로 C#의 else if 체인도 실제로는 else 블록 안에 또 다른 if가 중첩된 구조라는 점이 삼단계 시간대 예제(morning/day/evening)로 다시 확인됨 — 문법적 특수 케이스가 아니라 else+if의 자연스러운 조합. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
아침/낮/저녁 인사말을 시간(time) 값에 따라 세 가지로 분기하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained else-if — first true condition wins, rest skipped (C#):
|
||||
```csharp
|
||||
int time = 22;
|
||||
if (time < 10)
|
||||
{
|
||||
Console.WriteLine("Good morning.");
|
||||
}
|
||||
else if (time < 20)
|
||||
{
|
||||
Console.WriteLine("Good day.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Good evening.");
|
||||
}
|
||||
// Outputs "Good evening."
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Conditions Else]], [[CSharp Conditions Shorthand]], [[CSharp Switch]]
|
||||
- **참조 맥락:** Conditions 섹션 — Short Hand If...Else 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# The else if Statement — https://www.w3schools.com/cs/cs_conditions_elseif.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# The else if Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -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).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: csharp-constructors
|
||||
title: "C# Constructors"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["default constructor C#", "constructor parameters C#", "C# 생성자"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "constructors"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_constructors.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Constructors]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The "constructors save time" comparison at the end of this chapter directly rewrites the SAME Ford/Opel two-object example already shown across Class Members and Multiple Classes chapters — turning 8 lines of manual field assignment (`Ford.model = "Mustang"; Ford.color = "red"; Ford.year = 1969;` ×2) into 2 lines of parameterized construction (`new Car("Mustang", "Red", 1969)`), making constructors the payoff for a pattern this wiki has now seen written out the long way THREE times before finally being shown the short way — identical in spirit to C++'s constructor mechanism already covered in Topic_CPP, right down to the "name must match the class, no return type" rule and constructor overloading via differing parameter counts. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Constructor** — a special method that initializes an object; called automatically when an object of the class is created (`new Car()`). [S1]
|
||||
- **Naming rule** — the constructor's name MUST match the class name exactly, and it CANNOT have a return type (no `void`, no `int`, nothing). [S1]
|
||||
- **Default constructor** — every class has one even if you don't write it yourself; but the auto-generated one can't set initial field values the way a custom constructor can. [S1]
|
||||
- **Constructor parameters** — a constructor can take parameters just like any method, used to set field values at creation time (`public Car(string modelName) { model = modelName; }`). [S1]
|
||||
- **Multiple parameters** — a constructor can take as many parameters as needed, mapping each to a field. [S1]
|
||||
- **Constructor overloading** — like ordinary methods, constructors can be overloaded with different parameter counts/types. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Parameterless constructor setting a fixed value: `class Car { public string model; public Car() { model = "Mustang"; } static void Main(string[] args) { Car Ford = new Car(); Console.WriteLine(Ford.model); } }` → `"Mustang"`. [S1]
|
||||
- Single-parameter constructor: `public Car(string modelName) { model = modelName; } ... Car Ford = new Car("Mustang");` → `"Mustang"`. [S1]
|
||||
- Multi-parameter constructor: `public Car(string modelName, string modelColor, int modelYear) { model = modelName; color = modelColor; year = modelYear; } ... Car Ford = new Car("Mustang", "Red", 1969);` → `"Red 1969 Mustang"`. [S1]
|
||||
- Before/after comparison: manual field-by-field assignment for `Ford` and `Opel` (8 lines) collapses to `Car Ford = new Car("Mustang", "Red", 1969); Car Opel = new Car("Astra", "White", 2005);` (2 lines) with a parameterized constructor. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++ 생성자 규칙과 동일**: 생성자 이름이 클래스명과 일치해야 하고 반환 타입을 가질 수 없다는 규칙, 그리고 매개변수 개수로 오버로딩할 수 있다는 규칙이 Topic_CPP의 Constructors/Constructors Overloading 챕터와 차이가 없다는 점이 확인됨. [S1]
|
||||
- **이전 챕터들의 수동 필드 대입 패턴이 생성자로 압축됨**: Class Members와 Multiple Classes 챕터에서 반복적으로 보여준 "객체 생성 후 필드를 하나씩 대입"하는 8줄짜리 패턴이, 이번 챕터의 매개변수 생성자를 쓰면 2줄로 줄어든다는 것이 직접적인 비교로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Ford와 Opel 두 Car 객체를 생성자 없이 필드별로 수동 대입하는 방식과, 3개 매개변수를 받는 생성자로 한 줄에 생성하는 방식을 나란히 비교하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Manual field assignment vs. parameterized constructor — same result, less code (C#):
|
||||
```csharp
|
||||
// Without constructor
|
||||
Car Ford = new Car();
|
||||
Ford.model = "Mustang"; Ford.color = "red"; Ford.year = 1969;
|
||||
|
||||
// With constructor
|
||||
class Car
|
||||
{
|
||||
public string model, color;
|
||||
public int year;
|
||||
public Car(string modelName, string modelColor, int modelYear)
|
||||
{
|
||||
model = modelName; color = modelColor; year = modelYear;
|
||||
}
|
||||
}
|
||||
Car Ford2 = new Car("Mustang", "Red", 1969);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Classes Multi]], [[CSharp Access Modifiers]], [[CPP Constructors]], [[CPP Constructors Overloading]]
|
||||
- **참조 맥락:** Constructors 섹션의 유일 챕터 — Access Modifiers & Properties 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Constructors — https://www.w3schools.com/cs/cs_constructors.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Constructors" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: csharp-data-types
|
||||
title: "C# Data Types"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["int long float double bool char string sizes", "C# 데이터 타입"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "data-types"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_data_types.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Data Types]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# fixes its numeric type SIZES in the language spec itself (`int` = 4 bytes, `long` = 8 bytes, always, on every platform), unlike C where `int`/`long` sizes are implementation-defined and vary by compiler/platform (a recurring caveat throughout Topic_C's Data Types chapter) — trading C's "your mileage may vary" portability model for C#'s "the number never changes" guarantee, a direct consequence of C# always running on a single controlled runtime (.NET/CLR) rather than being compiled to arbitrary native targets. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Numeric types split into integer vs. floating-point** — integer types (`int`, `long`) store whole numbers; floating-point types (`float`, `double`) store fractional numbers. [S1]
|
||||
- **Fixed sizes** — `int` 4 bytes (-2,147,483,648 to 2,147,483,647), `long` 8 bytes (much larger range), `float` 4 bytes (~6-7 decimal digit precision), `double` 8 bytes (~15 decimal digit precision), `bool` 1 byte, `char` 2 bytes, `string` 2 bytes per character. [S1]
|
||||
- **Literal suffixes required** — `long` values need an `L` suffix (`15000000000L`), `float` values need `F` (`5.75F`), `double` values need `D` (`19.99D`) — the compiler needs the suffix to disambiguate which type the literal should be. [S1]
|
||||
- **float vs. double precision trade-off** — float's ~6-7 digit precision vs. double's ~15 digits is the explicit reason the tutorial recommends double for "most calculations." [S1]
|
||||
- **Scientific notation** — `float f1 = 35e3F; double d1 = 12E4D;` — the `e`/`E` indicates a power of 10. [S1]
|
||||
- **`int` and `double` as the default go-to types** — despite the full menu of numeric types, the tutorial states int (whole numbers) and double (decimals) are the most commonly used throughout. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Boolean: `bool isCSharpFun = true; bool isFishTasty = false;` — printed values are capitalized `True`/`False` (not lowercase `true`/`false`) in console output. [S1]
|
||||
- Char: `char myGrade = 'B';` — single quotes only. [S1]
|
||||
- String: `string greeting = "Hello World";` — double quotes only. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **타입 크기가 플랫폼에 관계없이 고정됨**: Topic_C의 Data Types 챕터는 int/long 등의 정확한 크기가 컴파일러/플랫폼마다 다를 수 있다는 점을 반복적으로 경고했지만, C#은 int=4바이트, long=8바이트 등으로 크기를 언어 명세 차원에서 고정한다는 점이 이번 챕터에서 확인됨 — .NET/CLR이라는 단일 통제된 런타임 위에서만 실행되기 때문에 가능한 보장. [S1]
|
||||
- **불리언 출력이 대문자로 표시됨**: `Console.WriteLine(isCSharpFun);`이 `True`(대문자 T)를 출력한다는 점이 확인됨 — C/C++가 0/1을 출력하거나 소문자 true/false를 요구하는 것과는 다른 표시 방식. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 7가지 데이터 타입 각각을 선언하고 출력하는 예제가 원문에서 개별적으로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Literal suffixes required for long/float/double (C#):
|
||||
```csharp
|
||||
int myInt = 100000;
|
||||
long myLong = 15000000000L; // L suffix required
|
||||
float myFloat = 5.75F; // F suffix required
|
||||
double myDouble = 19.99D; // D suffix required
|
||||
bool isCSharpFun = true; // prints "True"
|
||||
char myGrade = 'B';
|
||||
string greeting = "Hello World";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables]], [[CSharp Type Casting]], [[C Data Types]]
|
||||
- **참조 맥락:** Data Types & Type Casting 섹션 — Type Casting 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Data Types — https://www.w3schools.com/cs/cs_data_types.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Data Types" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: csharp-enums
|
||||
title: "C# Enum"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["enumerations C#", "enum switch C#", "C# 열거형"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "enums"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_enums.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Enums]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`Console.WriteLine(myVar)` on a C# enum prints the symbolic NAME (`"Medium"`), not the underlying integer — a real behavioral difference from C++'s enum, which prints its raw integer value when streamed through `cout <<` unless a custom conversion is written, meaning C# enums carry name-string-printability as a built-in feature (via an implicit `ToString()`) where C++ requires the programmer to bridge that gap manually; the auto-incrementing 0/1/2... numbering and the ability to override a starting value (which cascades to all subsequent members) otherwise matches the C++ enum model already documented in `[[CPP Enum]]`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`enum` keyword** — declares an enum instead of `class`/`interface`; members separated by commas, no explicit values required. [S1]
|
||||
- **Dot syntax access** — `Level myVar = Level.Medium;` — same pattern as accessing a static class member. [S1]
|
||||
- **Printing an enum prints its NAME** — `Console.WriteLine(myVar);` outputs `"Medium"`, not a number. [S1]
|
||||
- **Default integer values** — the first member is `0`, the second `1`, and so on, incrementing automatically. [S1]
|
||||
- **Explicit cast to get the integer** — `(int) Months.April` is required to retrieve the underlying numeric value; it isn't exposed by default. [S1]
|
||||
- **Custom starting values cascade forward** — assigning a value to one member (e.g. `March = 6`) shifts every SUBSEQUENT member's auto-incremented value accordingly (`April` becomes `7`, not `3`). [S1]
|
||||
- **Enums inside a class** — an enum can be declared as a member of a class, scoped to it. [S1]
|
||||
- **Enums in `switch`** — a natural fit for `switch` statements, matching each `case` against an enum member. [S1]
|
||||
- **Use case** — values known never to change: month names, weekdays, colors, card suits, etc. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic declaration + access: `enum Level { Low, Medium, High } ... Level myVar = Level.Medium; Console.WriteLine(myVar);` → `"Medium"`. [S1]
|
||||
- Enum inside a class: `class Program { enum Level { Low, Medium, High } static void Main(string[] args) { Level myVar = Level.Medium; Console.WriteLine(myVar); } }` → `"Medium"`. [S1]
|
||||
- Default numbering + explicit cast: `enum Months { January, February, March, April, May, June, July } ... int myNum = (int) Months.April;` → `3` (0-indexed). [S1]
|
||||
- Custom starting value cascading: `enum Months { January, February, March=6, April, May, June, July } ... int myNum = (int) Months.April;` → `7` (March=6 shifts April to 7, not the default 3). [S1]
|
||||
- Switch on enum: `switch(myVar) { case Level.Low: ...; break; case Level.Medium: Console.WriteLine("Medium level"); break; case Level.High: ...; break; }` → `"Medium level"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **enum을 출력하면 이름이 나옴(C++와 다름)**: C++에서 enum을 `cout <<`으로 출력하면 기본적으로 정수값이 나오지만(별도 변환 없이는 이름이 출력되지 않음), C#은 `Console.WriteLine(myVar)`가 곧바로 심볼릭 이름("Medium")을 출력한다는 점이 확인됨 — C#의 enum이 기본적으로 문자열 표현을 내장하고 있음을 보여줌. [S1]
|
||||
- **자동 증가·수동 재지정 방식은 C++의 enum과 동일**: 첫 멤버가 0부터 시작해 자동 증가하고, 특정 멤버에 값을 수동으로 지정하면 그 이후 멤버들이 그 값을 기준으로 다시 증가한다는 규칙이 `[[CPP Enum]]`에서 확인된 C++ enum 규칙과 차이가 없다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Level enum(Low/Medium/High)을 switch문에서 각 case와 매칭시켜 해당 레벨 메시지를 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Printing an enum prints its name; explicit cast needed for the integer value (C#):
|
||||
```csharp
|
||||
enum Level { Low, Medium, High }
|
||||
|
||||
Level myVar = Level.Medium;
|
||||
Console.WriteLine(myVar); // "Medium" -- name, not a number
|
||||
|
||||
int myNum = (int) Level.Medium; // explicit cast required
|
||||
Console.WriteLine(myNum); // 1
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Interface Multi]], [[CSharp Switch]], [[CSharp User Input]], [[CPP Enum]]
|
||||
- **참조 맥락:** Enums 섹션의 유일 챕터 — User Input 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Enum — https://www.w3schools.com/cs/cs_enums.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Enum" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,94 @@
|
||||
---
|
||||
id: csharp-exceptions
|
||||
title: "C# Exceptions - Try..Catch"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["try catch finally throw C#", "e.Message", "C# 예외 처리"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "exceptions"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_exceptions.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Exceptions]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `try { } catch (Exception e) { } finally { }` structure is functionally identical to C++'s exception handling already documented in `[[CPP Exceptions]]`, but where C++ typically catches by REFERENCE to a specific exception type (`catch (std::exception& e)`) and reads its message via `.what()`, C# catches the generic base `Exception` type and reads the message via a `.Message` PROPERTY (no parentheses — consistent with the property-not-method pattern already confirmed for `.Length` in the Strings chapter); `throw new ArithmeticException("...")` also demonstrates that C# ships a family of ready-made, semantically-named exception classes (`ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException`) rather than requiring the programmer to define custom exception types from scratch for common cases. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Exception** — the technical term for an error C# "throws" when something goes wrong (bad input, coding errors, unforeseen conditions). [S1]
|
||||
- **`try { }`** — a block of code tested for errors during execution. [S1]
|
||||
- **`catch (Exception e) { }`** — a block that runs IF an error occurs inside the paired `try` block; `e` is a variable holding the exception object. [S1]
|
||||
- **`e.Message`** — a property (no parentheses) on the caught exception, describing what went wrong. [S1]
|
||||
- **`finally { }`** — runs AFTER the try/catch, regardless of whether an error occurred or was caught. [S1]
|
||||
- **`throw new ExceptionType("message")`** — creates and raises a CUSTOM error, using one of C#'s built-in exception classes (`ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException`, etc.). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Unhandled error: `int[] myNumbers = {1, 2, 3}; Console.WriteLine(myNumbers[10]);` → `System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'`. [S1]
|
||||
- Caught with built-in message: `try { ...myNumbers[10]... } catch (Exception e) { Console.WriteLine(e.Message); }` → `"Index was outside the bounds of the array."`. [S1]
|
||||
- Caught with custom message: `catch (Exception e) { Console.WriteLine("Something went wrong."); }` → `"Something went wrong."` (note: `e` is available but not necessarily used). [S1]
|
||||
- With `finally`: adding `finally { Console.WriteLine("The 'try catch' is finished."); }` runs that line AFTER the catch block regardless of outcome. [S1]
|
||||
- Custom throw: `static void checkAge(int age) { if (age < 18) { throw new ArithmeticException("Access denied - You must be at least 18 years old."); } else { Console.WriteLine("Access granted - You are old enough!"); } } ... checkAge(15);` → throws `System.ArithmeticException: 'Access denied...'`; `checkAge(20);` → prints `"Access granted - You are old enough!"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++의 예외 처리와 구조는 동일, 메시지 접근 방식이 다름**: try/catch/finally 구조 자체는 `[[CPP Exceptions]]`에서 확인된 C++와 차이가 없지만, C++가 보통 `.what()` 메서드로 예외 메시지를 얻는 반면 C#은 `.Message`라는 프로퍼티(괄호 없음)로 접근한다는 점이 확인됨 — Strings 챕터에서 확인된 프로퍼티 vs 메서드 구분이 예외 객체에도 그대로 적용됨. [S1]
|
||||
- **즉시 사용 가능한 다양한 내장 예외 클래스 제공**: `ArithmeticException`, `FileNotFoundException`, `IndexOutOfRangeException`, `TimeOutException` 등 의미가 명확한 예외 클래스들이 기본 제공되어, throw할 때 매번 커스텀 예외 타입을 새로 정의할 필요가 없다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
나이가 18세 미만이면 ArithmeticException을 throw하고, 18세 이상이면 "Access granted"를 출력하는 checkAge() 함수 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
try/catch/finally with a custom throw (C#):
|
||||
```csharp
|
||||
static void checkAge(int age)
|
||||
{
|
||||
if (age < 18)
|
||||
{
|
||||
throw new ArithmeticException("Access denied - You must be at least 18 years old.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Access granted - You are old enough!");
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
checkAge(15);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message); // property, no parentheses
|
||||
}
|
||||
finally
|
||||
{
|
||||
Console.WriteLine("The 'try catch' is finished.");
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp User Input]], [[CSharp Files]], [[CPP Exceptions]], [[CSharp Strings]]
|
||||
- **참조 맥락:** Exceptions 섹션의 유일 챕터 — Files 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Exceptions - Try..Catch — https://www.w3schools.com/cs/cs_exceptions.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Exceptions - Try..Catch" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: csharp-files
|
||||
title: "C# Files"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["System.IO File class", "WriteAllText ReadAllText", "C# 파일"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "files"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_files.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Files]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# collapses file I/O into ONE-LINE static method calls on the `File` class (`File.WriteAllText("filename.txt", writeText);` / `File.ReadAllText("filename.txt")`) — a fundamentally different model from C++'s stream-object approach in `[[CPP Files]]` (create an `ofstream`/`ifstream` object, use `<<`/`getline()`, explicitly `.close()` it) or C's `fopen`/`fprintf`/`fclose` triad; there's no open/close lifecycle to manage at all in the basic C# examples shown here — `File.WriteAllText()` opens, writes, AND closes the file internally in a single call, trading the C-family's manual resource-management ceremony for a higher-level, one-shot convenience API. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`System.IO` namespace** — must be imported (`using System.IO;`) to access the `File` class. [S1]
|
||||
- **`File` class** — a static class (no instantiation, no `new File()`) offering methods for creating/reading/writing/deleting files. [S1]
|
||||
- **Key methods**: `AppendText()` (append to end), `Copy()` (copy a file), `Create()` (create/overwrite), `Delete()`, `Exists()` (test existence), `ReadAllText()` (read entire contents), `Replace()` (replace one file's contents with another's), `WriteAllText()` (create/overwrite AND write in one call). [S1]
|
||||
- **No explicit open/close** — unlike C++'s `ofstream`/`ifstream` objects (which must be created, used, then `.close()`d) or C's `fopen`/`fclose` pair, `File.WriteAllText()` and `File.ReadAllText()` handle the entire file lifecycle internally in a single static call. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Write then read: `using System.IO; string writeText = "Hello World!"; File.WriteAllText("filename.txt", writeText); string readText = File.ReadAllText("filename.txt"); Console.WriteLine(readText);` → outputs `"Hello World!"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **파일 생명주기 관리 방식이 C/C++와 근본적으로 다름**: `[[CPP Files]]`는 ofstream/ifstream 객체를 만들고 `<<`/`getline()`으로 쓰고 읽은 뒤 반드시 `.close()`를 호출해야 했고, C도 fopen/fprintf/fclose 3단계가 필요했지만, C#은 `File.WriteAllText()`/`File.ReadAllText()`라는 정적 메서드 한 번 호출로 열기-쓰기(또는 읽기)-닫기가 전부 내부적으로 처리된다는 점이 확인됨 — 객체 생성이나 명시적 close 호출이 전혀 없음. [S1]
|
||||
- **File은 인스턴스화되지 않는 정적 클래스**: `ofstream`/`ifstream`처럼 객체를 만드는 방식이 아니라, `File.MethodName()`처럼 클래스 이름으로 직접 호출하는 정적 메서드 모음이라는 점이 C++ 파일 클래스들과의 설계 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
"Hello World!"라는 문자열을 filename.txt에 WriteAllText()로 쓰고, 곧바로 ReadAllText()로 읽어 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
One-line file write and read — no explicit open/close lifecycle (C#):
|
||||
```csharp
|
||||
using System.IO;
|
||||
|
||||
string writeText = "Hello World!";
|
||||
File.WriteAllText("filename.txt", writeText); // create + write + close, all in one call
|
||||
|
||||
string readText = File.ReadAllText("filename.txt"); // open + read + close, all in one call
|
||||
Console.WriteLine(readText); // "Hello World!"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Exceptions]], [[CPP Files]], [[C Files]]
|
||||
- **참조 맥락:** Files 섹션의 유일 챕터이자 C# 튜토리얼의 마지막 챕터 — Topic_CSharp 전체 완료.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Files — https://www.w3schools.com/cs/cs_files.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Files" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
id: csharp-for-loop
|
||||
title: "C# For Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["nested loops C#", "C# for 반복문"]
|
||||
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", "loops", "for"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_for_loop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp For Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The three-statement `for (statement1; statement2; statement3)` structure and its nested-loop composition (outer loop's body containing a complete inner loop, with the inner loop restarting fully on every single outer iteration) are unchanged from C/C++ — the nested-loop iteration-count math shown here (`2 outer × 3 inner = 6 inner executions total`) is the same multiplicative relationship this wiki has already confirmed for C and C++ nested loops. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`for (statement1; statement2; statement3) { ... }`** — statement1 runs ONCE before the loop starts (initialization); statement2 is the condition checked before EVERY iteration; statement3 runs AFTER each iteration (typically increment/decrement). [S1]
|
||||
- **Step size is arbitrary** — statement3 doesn't have to be `i++`; it can be any expression, e.g. `i = i + 2` to iterate only even numbers. [S1]
|
||||
- **Nested loops** — a complete `for` loop placed inside another `for` loop's body; the inner loop runs to completion once for EVERY iteration of the outer loop. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic count: `for (int i = 0; i < 5; i++) { Console.WriteLine(i); }` → prints 0 through 4. [S1]
|
||||
- Step-by-2: `for (int i = 0; i <= 10; i = i + 2) { Console.WriteLine(i); }` → prints even numbers 0 through 10. [S1]
|
||||
- Nested loop with execution counts explicitly annotated:
|
||||
```
|
||||
for (int i = 1; i <= 2; ++i) {
|
||||
Console.WriteLine("Outer: " + i); // executes 2 times
|
||||
for (int j = 1; j <= 3; j++) {
|
||||
Console.WriteLine(" Inner: " + j); // executes 6 times total (2 * 3)
|
||||
}
|
||||
}
|
||||
```
|
||||
[S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **for문 구조와 중첩 반복 곱셈 관계가 C/C++와 동일**: 3-statement for 구조, 그리고 중첩 루프에서 "외부 루프 횟수 × 내부 루프 횟수"라는 곱셈 관계가 C/C++에서 확인된 것과 차이가 없다는 점이 이번 챕터에서 재확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
0-4 카운트, 짝수만 출력하는 step-2 루프, 2×3 중첩 루프의 실행 횟수를 주석으로 명시한 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Nested for loops — inner runs fully for each outer iteration (C#):
|
||||
```csharp
|
||||
for (int i = 1; i <= 2; ++i)
|
||||
{
|
||||
Console.WriteLine("Outer: " + i); // 2 times
|
||||
for (int j = 1; j <= 3; j++)
|
||||
{
|
||||
Console.WriteLine(" Inner: " + j); // 6 times total (2 * 3)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp While Loop]], [[CSharp Foreach Loop]], [[CPP For Loop Nested]]
|
||||
- **참조 맥락:** Loops 섹션 — Foreach Loop 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# For Loop — https://www.w3schools.com/cs/cs_for_loop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# For Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: csharp-foreach-loop
|
||||
title: "C# Foreach Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["foreach in C#", "C# foreach 반복문"]
|
||||
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", "loops", "foreach"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_foreach_loop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Foreach Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# spells its range-based loop as the dedicated keyword `foreach (type variableName in arrayName)`, whereas C++11's equivalent range-based for loop reuses the SAME `for` keyword with a colon (`for (type var : container)`) — same underlying concept (iterate every element without manual indexing) expressed through two genuinely different keywords, meaning "foreach" isn't just C++'s range-for renamed, it's C#'s own dedicated syntax that happens to solve the identical problem. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`foreach (type variableName in arrayName) { ... }`** — a loop construct used EXCLUSIVELY for iterating over elements of an array (or other data sets); no index variable, no manual bounds. [S1]
|
||||
- **`in` keyword** — connects the per-element variable to the collection being iterated, distinct from C++'s `:` colon syntax for the same relationship. [S1]
|
||||
- **No indexing needed** — unlike a `for` loop over an array (`arr[i]`), `foreach` never exposes an index; you only get direct access to each element's value. [S1]
|
||||
- **Deferred prerequisite** — the tutorial explicitly tells readers not to worry about the array syntax shown here, deferring full array coverage to the later Arrays chapter. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example: `string[] cars = {"Volvo", "BMW", "Ford", "Mazda"}; foreach (string i in cars) { Console.WriteLine(i); }` — prints all four car names, one per line. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **for가 아니라 별도 키워드 foreach를 사용함**: C++11의 범위 기반 for 루프(`for (string car : cars)`)는 기존 `for` 키워드를 콜론(:)과 함께 재사용했지만, C#은 `foreach`라는 완전히 별도의 전용 키워드와 `in`을 사용한다는 점이 확인됨 — 개념은 동일(인덱스 없이 각 원소 순회)하지만 문법 표현이 실제로 다름. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
자동차 이름이 담긴 문자열 배열을 foreach로 순회해 각 원소를 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
foreach — dedicated keyword + `in`, unlike C++'s `for ... :` syntax (C#):
|
||||
```csharp
|
||||
string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
|
||||
foreach (string i in cars)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp For Loop]], [[CSharp Break]], [[CSharp Arrays]], [[CPP For Loop Foreach]]
|
||||
- **참조 맥락:** Loops 섹션 — Break and Continue 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Foreach Loop — https://www.w3schools.com/cs/cs_foreach_loop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Foreach Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,92 @@
|
||||
---
|
||||
id: csharp-get-started
|
||||
title: "C# Get Started"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Visual Studio setup", "C# IDE", "C# 시작하기"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "setup", "visual-studio"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_getstarted.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Get Started]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike C/C++'s tutorial-neutral "any compiler will do" framing, this chapter names ONE specific tool — Visual Studio Community — as the recommended path, and justifies it not on technical merit but on ownership: "the program, the framework, and the language are all created by Microsoft," a same-vendor argument that has no equivalent in the C/C++ chapters (gcc/clang are not made by the same organization that wrote the C/C++ standard). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **IDE (Integrated Development Environment)** — used to edit and compile code; Visual Studio Community is the recommended free option. [S1]
|
||||
- **Same-vendor stack** — Visual Studio, the .NET Framework, and C# are all Microsoft products, which is given as the reason to prefer Visual Studio specifically. [S1]
|
||||
- **Console App (.NET Core)** project template — the starting project type used throughout the tutorial. [S1]
|
||||
- **Auto-generated boilerplate** — creating a new console project auto-generates a `Program.cs` file containing `using System;`, a `namespace`, a `class Program`, and a `static void Main(string[] args)` method with a `Console.WriteLine("Hello World!");` call — introduced here without explanation, to be unpacked in the next chapter (Syntax). [S1]
|
||||
- **F5 to run** — pressing F5 (or Debug → Start Debugging) compiles and executes the code. [S1]
|
||||
- **W3Schools "Try it Yourself"** — the tutorial's own in-browser alternative to installing Visual Studio, used throughout the rest of the series. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full auto-generated starter file:
|
||||
```
|
||||
using System;
|
||||
namespace HelloWorld
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
[S1]
|
||||
- Expected console output after running: `Hello World!` followed by a process-exit message. [S1]
|
||||
- A debugging option is mentioned to auto-close the console window when debugging stops (Tools → Options → Debugging). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **툴체인 선택이 언어와 결합됨**: C/C++ 튜토리얼은 컴파일러 선택을 사용자에게 맡기고 어떤 표준 준수 컴파일러든 무방하다는 전제였지만, C#은 처음부터 "언어·프레임워크·IDE가 모두 같은 회사 제품"이라는 이유로 Visual Studio를 사실상 유일한 권장 경로로 제시한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Visual Studio에서 새 Console App (.NET Core) 프로젝트를 생성하고 F5로 실행해 "Hello World!"를 출력하는 전체 설치→실행 흐름이 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Auto-generated Visual Studio console app boilerplate (C#):
|
||||
```csharp
|
||||
using System;
|
||||
namespace HelloWorld
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Intro]], [[CSharp Syntax]]
|
||||
- **참조 맥락:** Basics 섹션 — Syntax 챕터로 이어짐(이 챕터에서 등장한 보일러플레이트를 한 줄씩 설명).
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Get Started — https://www.w3schools.com/cs/cs_getstarted.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Get Started" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: csharp-inheritance
|
||||
title: "C# Inheritance"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["derived base class C#", "sealed keyword C#", "C# 상속"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "inheritance"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_inheritance.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Inheritance]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s inheritance syntax `class Car : Vehicle` OMITS the access specifier that C++'s equivalent `class Car : public Vehicle` REQUIRES — C# never lets you write `class Car : private Vehicle`, because member-level access (public/private/protected on each field/method) is the only lever C# offers, unlike C++ which layers an ADDITIONAL access specifier onto the inheritance relationship itself; and where C++ uses `final` to block further subclassing, C# uses a differently-named but functionally identical `sealed` keyword. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Derived class (child)** — the class that inherits from another class. [S1]
|
||||
- **Base class (parent)** — the class being inherited from. [S1]
|
||||
- **`:` syntax** — `class Car : Vehicle` — no access specifier before the base class name, unlike C++'s `class Car : public Vehicle`. [S1]
|
||||
- **Inherited members** — a derived class gains ALL fields and methods from its base class, callable/accessible directly on the derived class's own objects. [S1]
|
||||
- **Motivation** — code reusability: reuse an existing class's fields/methods instead of rewriting them in the new class. [S1]
|
||||
- **`sealed` keyword** — prevents a class from being inherited at all; attempting to derive from a sealed class is a compile error (`'Car': cannot derive from sealed type 'Vehicle'`). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full example: `class Vehicle { public string brand = "Ford"; public void honk() { Console.WriteLine("Tuut, tuut!"); } } class Car : Vehicle { public string modelName = "Mustang"; } ... Car myCar = new Car(); myCar.honk(); Console.WriteLine(myCar.brand + " " + myCar.modelName);` → calls the PARENT's `honk()` and reads the PARENT's `brand` field directly on a `Car` object, alongside `Car`'s own `modelName`. [S1]
|
||||
- Sealed class blocking inheritance: `sealed class Vehicle { ... } class Car : Vehicle { ... }` → compile error. [S1]
|
||||
- The tutorial explicitly points forward to Polymorphism as building on inherited methods to perform different tasks. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **상속 문법에 접근 지정자가 없음**: C++는 `class Car : public Vehicle`처럼 상속 관계 자체에 public/private/protected 접근 지정자를 붙여야 했지만, C#은 `class Car : Vehicle`처럼 이 지정자 없이 상속하며, 접근 제어는 오직 멤버 단위(각 필드/메서드의 public/private/protected)로만 이뤄진다는 점이 확인됨. [S1]
|
||||
- **final 대신 sealed라는 다른 이름의 동일 개념**: C++11의 `final` 키워드와 동일한 역할(더 이상 상속 불가)을 C#은 `sealed`라는 이름으로 제공한다는 점이 확인됨 — 개념은 같지만 키워드가 다름. [S1]
|
||||
- **원문 구조상 상속이 단일 챕터로 압축됨**: Topic_CPP는 Inheritance/Access/Multilevel/Multiple을 4개 문서로 나눴지만, C# 사이드바는 cs_inheritance.php 단 하나로 기본 상속과 sealed를 모두 다룬다는 점이 확인됨 — 다단계·다중 상속에 대한 별도 챕터가 C# 튜토리얼에는 없음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Vehicle(부모)의 brand 필드와 honk() 메서드를 Car(자식)가 상속받아 Car 객체에서 그대로 사용하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Inheritance without an access specifier on the base class (C#):
|
||||
```csharp
|
||||
class Vehicle
|
||||
{
|
||||
public string brand = "Ford";
|
||||
public void honk()
|
||||
{
|
||||
Console.WriteLine("Tuut, tuut!");
|
||||
}
|
||||
}
|
||||
class Car : Vehicle // no `public`/`private` before Vehicle, unlike C++
|
||||
{
|
||||
public string modelName = "Mustang";
|
||||
}
|
||||
|
||||
Car myCar = new Car();
|
||||
myCar.honk(); // inherited method
|
||||
Console.WriteLine(myCar.brand + " " + myCar.modelName); // inherited field + own field
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Properties]], [[CSharp Polymorphism]], [[CPP Inheritance]]
|
||||
- **참조 맥락:** Inheritance 섹션의 유일 챕터 — Polymorphism & Abstract 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Inheritance — https://www.w3schools.com/cs/cs_inheritance.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Inheritance" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,84 @@
|
||||
---
|
||||
id: csharp-interface
|
||||
title: "C# Interface"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["interface implements C#", "IAnimal", "C# 인터페이스"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "interface"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_interface.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Interface]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The tutorial states outright why interfaces exist at all: "C# does not support 'multiple inheritance' (a class can only inherit from ONE base class)" — a hard restriction with NO equivalent in Topic_CPP, where C++ freely supports true multiple class inheritance (`class Derived : public Base1, public Base2`, already documented in `[[CPP Inheritance Multiple]]`) — so C# compensates by letting a class implement MANY interfaces via the SAME `:` syntax used for single-class inheritance, making interfaces less a stylistic alternative to abstract classes and more a structural workaround for a capability C# deliberately doesn't offer at the class level. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Interface** — a "completely abstract class" containing ONLY abstract methods and properties with empty bodies; no fields/variables allowed. [S1]
|
||||
- **Naming convention** — interfaces are conventionally prefixed with `I` (e.g. `IAnimal`) to distinguish them from ordinary classes at a glance. [S1]
|
||||
- **Default member modifiers** — interface members are implicitly `abstract` AND `public`, with no need to write those keywords. [S1]
|
||||
- **Implementation via `:`** — the SAME symbol used for inheritance; a class "implements" an interface using `:`, and must provide bodies for ALL the interface's methods. [S1]
|
||||
- **No `override` keyword needed** — unlike overriding a `virtual` base method, implementing an interface method requires no `override` keyword at all. [S1]
|
||||
- **Cannot instantiate an interface directly** — like an abstract class, an interface can never be `new`'d into an object. [S1]
|
||||
- **No constructors** — an interface cannot have a constructor, since it can never be instantiated. [S1]
|
||||
- **Motivation #2, stated explicitly** — because C# disallows multiple class inheritance, interfaces are the mechanism for achieving multiple-inheritance-like behavior (a class implementing several interfaces). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Interface declaration: `interface Animal { void animalSound(); void run(); }` — both methods bodyless. [S1]
|
||||
- Implementation: `interface IAnimal { void animalSound(); } class Pig : IAnimal { public void animalSound() { Console.WriteLine("The pig says: wee wee"); } } ... Pig myPig = new Pig(); myPig.animalSound();`. [S1]
|
||||
- Explicit note that `IAnimal myObj = new IAnimal();` would be impossible, mirroring the abstract class restriction. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **다중 상속 부재를 인터페이스로 보완함**: C++는 `class Derived : public Base1, public Base2`처럼 여러 클래스를 동시에 상속하는 진짜 다중 상속을 지원했지만(`[[CPP Inheritance Multiple]]`), C#은 클래스 단위 다중 상속을 아예 지원하지 않고 대신 여러 인터페이스를 구현(implement)하는 방식으로 유사한 효과를 낸다는 점이 원문에서 직접 그 이유로 명시됨. [S1]
|
||||
- **인터페이스 구현에는 override가 필요 없음**: Abstract 챕터에서 abstract 클래스를 상속할 때는 override 키워드가 필수였지만, 인터페이스를 implement할 때는 override 없이 그냥 메서드를 정의하면 된다는 차이가 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
IAnimal 인터페이스의 animalSound() 메서드를 Pig 클래스가 override 없이 그대로 구현해 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Interface implementation — no `override` keyword required (C#):
|
||||
```csharp
|
||||
interface IAnimal
|
||||
{
|
||||
void animalSound(); // no body
|
||||
}
|
||||
class Pig : IAnimal // "implements" -- same : syntax as inheritance
|
||||
{
|
||||
public void animalSound() // no `override` needed
|
||||
{
|
||||
Console.WriteLine("The pig says: wee wee");
|
||||
}
|
||||
}
|
||||
|
||||
Pig myPig = new Pig();
|
||||
myPig.animalSound();
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Abstract]], [[CSharp Interface Multi]], [[CPP Inheritance Multiple]]
|
||||
- **참조 맥락:** Interface 섹션 — Multiple Interfaces 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Interface — https://www.w3schools.com/cs/cs_interface.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Interface" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: csharp-interface-multi
|
||||
title: "C# Multiple Interfaces"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["implement multiple interfaces 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", "oop", "interface"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_interface_multi.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Interface Multi]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This short chapter delivers exactly the payoff the previous Interface chapter promised: a single class implementing MULTIPLE interfaces via a comma-separated list after `:` (`class DemoClass : IFirstInterface, ISecondInterface`) — this is as close as C# gets to C++'s multiple inheritance, but the constraint is real: every interface in the list contributes only bodyless method signatures, never actual field data or base implementation, so C# is achieving multiple "contracts" rather than C++'s multiple actual base-class STATE and behavior. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comma-separated interface list** — `class DemoClass : IFirstInterface, ISecondInterface { ... }` — any number of interfaces can follow the `:`. [S1]
|
||||
- **Each interface method must be implemented** — the implementing class must provide a body for every method declared across ALL implemented interfaces. [S1]
|
||||
- **Still no shared state from interfaces** — since interfaces can't contain fields (per the previous chapter), implementing multiple interfaces never brings in multiple sets of DATA, only multiple sets of METHOD CONTRACTS. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Two interfaces: `interface IFirstInterface { void myMethod(); } interface ISecondInterface { void myOtherMethod(); }`. [S1]
|
||||
- Combined implementation: `class DemoClass : IFirstInterface, ISecondInterface { public void myMethod() { Console.WriteLine("Some text.."); } public void myOtherMethod() { Console.WriteLine("Some other text..."); } }`. [S1]
|
||||
- Usage: `DemoClass myObj = new DemoClass(); myObj.myMethod(); myObj.myOtherMethod();` → prints both messages. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++ 다중 상속의 데이터 상속과 달리 계약(메서드 시그니처)만 상속됨**: C++의 다중 상속(`[[CPP Inheritance Multiple]]`)은 여러 베이스 클래스의 실제 필드와 구현을 함께 물려받았지만, C#의 다중 인터페이스 구현은 인터페이스가 필드를 가질 수 없으므로 메서드 시그니처(계약)만 여러 개 물려받는다는 점이 확인됨 — 실질적으로 더 제한된 형태의 "다중 상속". [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
IFirstInterface와 ISecondInterface 두 인터페이스를 DemoClass 하나가 동시에 구현해 두 메서드를 모두 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Implementing two interfaces in one class, comma-separated (C#):
|
||||
```csharp
|
||||
interface IFirstInterface { void myMethod(); }
|
||||
interface ISecondInterface { void myOtherMethod(); }
|
||||
|
||||
class DemoClass : IFirstInterface, ISecondInterface
|
||||
{
|
||||
public void myMethod() { Console.WriteLine("Some text.."); }
|
||||
public void myOtherMethod() { Console.WriteLine("Some other text..."); }
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Interface]], [[CSharp Enums]], [[CPP Inheritance Multiple]]
|
||||
- **참조 맥락:** Interface 섹션의 마지막 챕터 — Enums 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Multiple Interfaces — https://www.w3schools.com/cs/cs_interface_multi.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Multiple Interfaces" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: csharp-intro
|
||||
title: "C# Introduction"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["What is C#", "C-Sharp", "C# 소개"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.87
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "intro"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_intro.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Intro]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# is explicitly introduced as sitting in the SAME "C family" lineage as the two languages this wiki just finished (C, C++) plus Java, but with a decisive fork: it's not an independent open standard like C/C++, it's a Microsoft-owned language tied to the .NET Framework — meaning the "which compiler/runtime do I use" question that barely mattered for C/C++ (any standards-compliant compiler works) becomes central for C# (tooling is Microsoft-specific, as the next chapter's Visual-Studio-only "Get Started" flow will confirm). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **C# ("C-Sharp")** — an object-oriented programming language created by Microsoft, runs on the .NET Framework. [S1]
|
||||
- **Family lineage** — has roots in the C family; syntactically close to C++ and Java (explicitly stated, not implied). [S1]
|
||||
- **History** — first released in 2002; latest version at time of writing is C# 13 (November 2024). [S1]
|
||||
- **Use cases** — mobile apps, desktop apps, web apps/services/sites, games, VR, database applications. [S1]
|
||||
- **Why C#** — popularity, ease of learning, huge community support, object-oriented structure enabling code reuse (lowers development cost), and easy migration to/from C/C++/Java due to syntactic closeness. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- No prior programming experience is assumed for the tutorial. [S1]
|
||||
- The explicit "close to C, C++, and Java" claim is the tutorial's own framing for why switching between these languages is easy — a claim this wiki can directly test chapter-by-chapter against the already-completed Topic_C/Topic_CPP/Topic_Java. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++는 특정 회사 소유가 아니었지만 C#은 Microsoft 소유**: Topic_C/Topic_CPP는 언어 표준이 특정 기업에 종속되지 않았지만(ISO 표준), C#은 Microsoft가 만들고 .NET Framework 위에서 동작하는 언어라는 점이 이번 챕터에서 확인된 근본적 차이 — 이는 다음 챕터(Get Started)에서 Visual Studio 전용 설치 절차로 구체화됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 모바일/데스크톱/웹 앱, 게임, VR, 데이터베이스 애플리케이션 등 광범위한 사용처가 원문에서 나열됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
없음 — 이 챕터는 코드 예제가 없는 개념 소개 챕터.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.87
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Get Started]], [[CPP Intro]], [[Java Intro]]
|
||||
- **참조 맥락:** C# 튜토리얼의 첫 챕터 — Get Started로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Introduction — https://www.w3schools.com/cs/cs_intro.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Introduction" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: csharp-math
|
||||
title: "C# Math"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Math.Max Math.Min Math.Sqrt", "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", "math"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_math.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Math]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Where C provides math functions as free-standing functions from `<math.h>` (`sqrt()`, `fabs()`) and C++ inherits that same free-function model (optionally namespaced as `std::sqrt`), C# packages every math operation as a STATIC METHOD of a `Math` CLASS (`Math.Sqrt()`, `Math.Max()`) — a direct, small-scale demonstration of the Syntax chapter's earlier rule that everything in C# must live inside a class, extended here to even the standard library's most basic utility functions. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`Math.Max(x, y)`** — returns the higher of two values. [S1]
|
||||
- **`Math.Min(x, y)`** — returns the lower of two values. [S1]
|
||||
- **`Math.Sqrt(x)`** — returns the square root of `x`. [S1]
|
||||
- **`Math.Abs(x)`** — returns the absolute (positive) value of `x`. [S1]
|
||||
- **`Math.Round()`** — rounds a number to the nearest whole number. [S1]
|
||||
- All are static methods called through the `Math` class name — no instance of `Math` is ever created. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `Math.Max(5, 10);` → 10. [S1]
|
||||
- `Math.Min(5, 10);` → 5. [S1]
|
||||
- `Math.Sqrt(64);` → 8. [S1]
|
||||
- `Math.Abs(-4.7);` → 4.7. [S1]
|
||||
- `Math.Round(9.99);` → 10. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **자유 함수(free function)가 아니라 클래스 정적 메서드로 제공됨**: C는 `<math.h>`의 `sqrt()`/`fabs()`를 자유 함수로 호출했고 C++도 이 모델을 그대로 계승했지만, C#은 이를 모두 `Math` 클래스의 정적 메서드(`Math.Sqrt()`, `Math.Abs()`)로 감쌌다는 점이 확인됨 — Syntax 챕터에서 확립된 "모든 코드는 클래스 안에" 원칙이 표준 라이브러리 함수에도 그대로 적용된 사례. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Max/Min/Sqrt/Abs/Round 각각의 최소 호출 예제가 원문에서 개별적으로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Math operations as static methods of the Math class (C#):
|
||||
```csharp
|
||||
Math.Max(5, 10); // 10
|
||||
Math.Min(5, 10); // 5
|
||||
Math.Sqrt(64); // 8
|
||||
Math.Abs(-4.7); // 4.7
|
||||
Math.Round(9.99); // 10
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Operators]], [[CSharp Strings]], [[CPP Math]], [[C Math Random]]
|
||||
- **참조 맥락:** Math 섹션의 유일 챕터 — Strings 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Math — https://www.w3schools.com/cs/cs_math.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Math" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: csharp-method-overloading
|
||||
title: "C# Method Overloading"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["overload same name different parameters", "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", "methods", "overloading"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_method_overloading.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Method Overloading]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Method overloading in C# (`PlusMethod(int, int)` and `PlusMethod(double, double)` sharing one name) is conceptually and syntactically identical to C++'s function overloading already covered in Topic_CPP — same rule ("as long as the number and/or type of parameters are different"), same motivating example structure (separately-named `PlusMethodInt`/`PlusMethodDouble` refactored into one overloaded `PlusMethod`) — reconfirming that C#'s object-oriented mechanics inherited directly from C++ rather than diverging, unlike the parameter-passing extensions (named arguments) covered in the immediately preceding chapter. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Method overloading** — multiple methods sharing the SAME name but differing in number and/or type of parameters. [S1]
|
||||
- **Compiler resolves by signature** — the compiler picks the correct overload based on the argument types/count supplied at the call site. [S1]
|
||||
- **Motivation** — avoids needing distinctly-named methods (`PlusMethodInt`, `PlusMethodDouble`) for functionally identical operations across different types. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Before overloading (distinct names): `static int PlusMethodInt(int x, int y) { return x + y; } static double PlusMethodDouble(double x, double y) { return x + y; }`. [S1]
|
||||
- After overloading (shared name): `static int PlusMethod(int x, int y) { return x + y; } static double PlusMethod(double x, double y) { return x + y; }` — called as `PlusMethod(8, 5)` (resolves to int version) and `PlusMethod(4.3, 6.26)` (resolves to double version). [S1]
|
||||
- General signature examples cited: `int MyMethod(int x)`, `float MyMethod(float x)`, `double MyMethod(double x, double y)` — all valid overloads of `MyMethod`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++의 함수 오버로딩과 개념·문법이 동일**: 매개변수 개수/타입만 다르면 같은 이름을 여러 메서드가 공유할 수 있다는 규칙과 예제 구성 방식이 Topic_CPP의 Function Overloading 챕터와 차이가 없다는 점이 확인됨 — 이전 챕터(Named Arguments)의 C/C++ 대비 확장과는 달리, 오버로딩은 C++에서 그대로 계승된 메커니즘. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
서로 다른 이름의 두 메서드(PlusMethodInt/PlusMethodDouble)를 하나의 오버로드된 PlusMethod로 리팩터링하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Overloading the same method name for different parameter types (C#):
|
||||
```csharp
|
||||
static int PlusMethod(int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
static double PlusMethod(double x, double y)
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
int myNum1 = PlusMethod(8, 5); // resolves to int version
|
||||
double myNum2 = PlusMethod(4.3, 6.26); // resolves to double version
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Method Parameters Named Args]], [[CSharp Method Parameters Return]], [[CPP Function Overloading]]
|
||||
- **참조 맥락:** Methods 섹션의 마지막 챕터 — Return Values 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Method Overloading — https://www.w3schools.com/cs/cs_method_overloading.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Method Overloading" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: csharp-method-parameters
|
||||
title: "C# Method Parameters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["parameters vs arguments 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", "methods", "parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_method_parameters.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Method Parameters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The parameter/argument distinction and the positional-matching rule ("the method call must have the same number of arguments as there are parameters, and the arguments must be passed in the same order") are unchanged from C/C++ — this chapter introduces no new C#-specific behavior, serving instead as the terminology foundation the next four chapters (Default Values, Named Arguments, Overloading, Return Values) will each independently break or extend. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Parameter** — a variable listed in the method's definition, inside the parentheses. [S1]
|
||||
- **Argument** — the actual value passed to a parameter when the method is CALLED. [S1]
|
||||
- **Multiple parameters** — separated by commas in both the definition and the call. [S1]
|
||||
- **Positional matching (default rule)** — argument count and order must match the parameter list exactly, unless named arguments (a later chapter) are used instead. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single parameter: `static void MyMethod(string fname) { Console.WriteLine(fname + " Refsnes"); } ... MyMethod("Liam"); MyMethod("Jenny"); MyMethod("Anja");` → `"Liam Refsnes"`, `"Jenny Refsnes"`, `"Anja Refsnes"`. [S1]
|
||||
- Multiple parameters: `static void MyMethod(string fname, int age) { Console.WriteLine(fname + " is " + age); } ... MyMethod("Liam", 5);` → `"Liam is 5"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **매개변수/인자 구분과 위치 일치 규칙이 C/C++와 동일**: 매개변수(parameter)와 인자(argument)의 구분, 그리고 호출 시 인자 개수·순서가 매개변수와 정확히 일치해야 한다는 규칙이 C/C++와 차이가 없다는 점이 확인됨 — 이후 챕터들(기본값, 이름 있는 인자, 오버로딩, 반환값)이 이 기본 규칙을 각각 다르게 확장/완화함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
이름(fname) 하나만 받는 메서드와, 이름+나이(age) 두 개를 받는 메서드를 각각 여러 인자로 반복 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Multiple parameters — count and order must match the call (C#):
|
||||
```csharp
|
||||
static void MyMethod(string fname, int age)
|
||||
{
|
||||
Console.WriteLine(fname + " is " + age);
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MyMethod("Liam", 5);
|
||||
MyMethod("Jenny", 8);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Methods]], [[CSharp Method Parameters Default]], [[CPP Function Param]]
|
||||
- **참조 맥락:** Methods 섹션 — Default Parameter Value 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Method Parameters — https://www.w3schools.com/cs/cs_method_parameters.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Method Parameters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,74 @@
|
||||
---
|
||||
id: csharp-method-parameters-default
|
||||
title: "C# Default Parameter Value"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["optional parameter C#", "default value = 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", "methods", "default-parameters"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_method_parameters_default.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Default Parameter Value]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `=` default-value syntax (`string country = "Norway"`) is identical to C++'s default parameter syntax already covered in Topic_CPP — the strict positional-matching rule from the previous chapter ("same number of arguments as parameters") gets its FIRST exception here: calling `MyMethod()` with zero arguments is now valid specifically because the parameter itself supplies a fallback, making "optional parameter" and "default parameter value" two names for the exact same mechanism. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Default parameter value** — assigned with `=` in the method signature: `static void MyMethod(string country = "Norway")`. [S1]
|
||||
- **"Optional parameter"** — the tutorial's alternate name for a parameter with a default value; calling the method WITHOUT that argument is now valid (breaking the prior chapter's strict count-matching rule). [S1]
|
||||
- **Overriding the default** — passing an explicit argument still overrides the default value normally. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- `static void MyMethod(string country = "Norway") { Console.WriteLine(country); } ... MyMethod("Sweden"); MyMethod("India"); MyMethod(); MyMethod("USA");` → outputs `Sweden`, `India`, `Norway` (default used when no argument given), `USA`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **인자 개수 일치 규칙의 첫 예외**: Method Parameters 챕터에서 확립된 "인자 개수가 매개변수 개수와 정확히 일치해야 한다"는 규칙이, 기본값이 있는 매개변수에 한해 예외적으로 완화된다는 점이 확인됨 — `MyMethod();`처럼 인자 없이 호출해도 유효함. [S1]
|
||||
- **C++의 기본 매개변수 문법과 동일**: `=` 기호로 기본값을 지정하는 문법이 Topic_CPP의 Default Parameters 챕터와 차이가 없다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
country 매개변수에 기본값 "Norway"를 지정한 뒤, 인자를 주거나 주지 않고 네 번 호출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Default parameter value — makes the argument optional (C#):
|
||||
```csharp
|
||||
static void MyMethod(string country = "Norway")
|
||||
{
|
||||
Console.WriteLine(country);
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MyMethod("Sweden"); // Sweden
|
||||
MyMethod(); // Norway (default used)
|
||||
MyMethod("USA"); // USA
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Method Parameters]], [[CSharp Method Parameters Named Args]], [[CPP Function Default]]
|
||||
- **참조 맥락:** Methods 섹션 — Named Arguments 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Default Parameter Value — https://www.w3schools.com/cs/cs_method_parameters_default.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Default Parameter Value" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: csharp-method-parameters-named-args
|
||||
title: "C# Named Arguments"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["key: value arguments 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", "methods", "named-arguments"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_method_parameters_named_args.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Named Arguments]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Named arguments (`MyMethod(child3: "John", child1: "Liam", child2: "Liam")`) break the SECOND half of Method Parameters' positional-matching rule entirely — order no longer matters as long as each argument is labeled with its parameter name via `key: value` syntax — and this is a genuinely NEW capability with no equivalent shown in this wiki's C or C++ chapters (C++ has no built-in named-argument syntax; arguments there are strictly positional, defaults aside), making this the clearest example so far of C# extending beyond, not just matching, the C-family function-call model. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Named argument syntax** — `parameterName: value`, passed in the method call regardless of the parameter's declared position. [S1]
|
||||
- **Order independence** — since each argument is explicitly labeled, the CALLER's argument order no longer needs to match the method's DEFINITION order. [S1]
|
||||
- **No equivalent in C/C++** — this wiki's C and C++ chapters never introduced a comparable mechanism; all their parameter-passing was strictly positional (with default values as the only relaxation). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example: `static void MyMethod(string child1, string child2, string child3) { Console.WriteLine("The youngest child is: " + child3); } ... MyMethod(child3: "John", child1: "Liam", child2: "Liam");` → despite `child3` being named FIRST in the call (out of definition order), it correctly binds to the `child3` parameter, printing `"The youngest child is: John"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++에 존재하지 않는 완전히 새로운 기능**: Method Parameters 챕터에서 확립된 "인자는 매개변수와 같은 순서로 전달돼야 한다"는 규칙이 이름 있는 인자(named argument)를 쓰면 완전히 무력화된다는 점이 확인됨 — C/C++는 이런 key:value 인자 전달 문법 자체가 없어 항상 위치 기반으로만 인자를 전달해야 했음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
세 자녀 이름을 매개변수 정의 순서와 다르게(child3 먼저) key:value 형태로 전달해도 올바르게 바인딩되는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Named arguments — call order can differ from definition order (C#):
|
||||
```csharp
|
||||
static void MyMethod(string child1, string child2, string child3)
|
||||
{
|
||||
Console.WriteLine("The youngest child is: " + child3);
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MyMethod(child3: "John", child1: "Liam", child2: "Liam");
|
||||
// Outputs "The youngest child is: John" -- order doesn't matter
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Method Parameters Default]], [[CSharp Method Overloading]], [[CPP Function Overloading]]
|
||||
- **참조 맥락:** Methods 섹션 — Method Overloading 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Named Arguments — https://www.w3schools.com/cs/cs_method_parameters_named_args.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Named Arguments" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: csharp-method-parameters-return
|
||||
title: "C# Return Values"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["return keyword 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", "methods", "return"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_method_parameters_return.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Method Parameters Return]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter closes the loop on `void` — first mentioned back in the Methods chapter as "no return value, details later" — by showing that swapping `void` for a concrete type (`int`) plus adding a `return` statement is the entire mechanism, identical to C/C++'s return-value model; the tutorial also states an explicit style preference (store the result in a variable rather than nesting the call directly inside `Console.WriteLine()`) purely for readability/maintainability, not because of any functional difference between the two forms. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Return type replaces `void`** — using `int` (or another primitive type) instead of `void` in the method signature signals the method WILL return a value of that type. [S1]
|
||||
- **`return` keyword** — ends the method and sends a value back to the caller. [S1]
|
||||
- **Return value as a direct expression argument** — `Console.WriteLine(MyMethod(3));` calls and prints in one line. [S1]
|
||||
- **Storing in a variable (recommended style)** — `int z = MyMethod(5, 3); Console.WriteLine(z);` — functionally identical, but preferred for readability and maintainability. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Single parameter with return: `static int MyMethod(int x) { return 5 + x; } ... Console.WriteLine(MyMethod(3));` → `8`. [S1]
|
||||
- Two parameters with return: `static int MyMethod(int x, int y) { return x + y; } ... Console.WriteLine(MyMethod(5, 3));` → `8`. [S1]
|
||||
- Stored-variable style: `int z = MyMethod(5, 3); Console.WriteLine(z);` → `8`, same result, explicitly called out as the recommended approach. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **void→구체 타입 전환이 C/C++의 반환값 모델과 동일**: `void`를 `int` 등으로 바꾸고 `return`을 추가하는 것만으로 반환값이 생긴다는 메커니즘이 C/C++와 차이가 없다는 점이 확인됨 — Methods 챕터에서 미뤄뒀던 void의 의미가 이번 챕터에서 완전히 설명됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
반환값을 바로 Console.WriteLine()에 중첩해 출력하는 방식과, 변수에 먼저 저장한 뒤 출력하는 방식 두 가지를 비교하며 후자를 권장하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Return value used directly vs. stored in a variable first (recommended) (C#):
|
||||
```csharp
|
||||
static int MyMethod(int x, int y)
|
||||
{
|
||||
return x + y;
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine(MyMethod(5, 3)); // direct -- works, but less readable
|
||||
|
||||
int z = MyMethod(5, 3); // recommended -- easier to read/maintain
|
||||
Console.WriteLine(z);
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Method Overloading]], [[CSharp Methods]], [[CSharp OOP]], [[CPP Function Return]]
|
||||
- **참조 맥락:** Methods 섹션의 마지막 챕터 — OOP Basics 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Return Values — https://www.w3schools.com/cs/cs_method_parameters_return.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Return Values" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,79 @@
|
||||
---
|
||||
id: csharp-methods
|
||||
title: "C# Methods"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["static void method C#", "PascalCase methods", "C# 메서드"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "methods"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_methods.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Methods]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# calls these "methods" and only parenthetically notes "also known as functions" — a terminology choice with real teeth, since the Syntax chapter's rule that ALL code must live inside a class means C# genuinely has no free-standing functions the way C++ does; every "function" is necessarily a method of SOME class (even `Main()` itself lives inside `class Program`), and the naming-convention split flagged back in the Identifiers chapter (variables lowercase-first) is completed here: methods are explicitly recommended to start UPPERCASE (`MyMethod`), giving C# a hard camelCase-vs-PascalCase split by identifier KIND that neither C nor C++ enforces as a style convention. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Method** — a block of code that only runs when called; used to perform actions and enable code reuse (define once, use many times). [S1]
|
||||
- **`static void MethodName() { ... }`** — the minimal method skeleton, defined inside a class. [S1]
|
||||
- **`static`** — means the method belongs to the CLASS itself, not to an object/instance of the class (object-based method access deferred to a later chapter). [S1]
|
||||
- **`void`** — means the method has no return value (deferred detail to the Return Values chapter). [S1]
|
||||
- **PascalCase convention** — method names should start with an UPPERCASE letter for readability, in contrast to the lowercase-starting convention recommended for variable names. [S1]
|
||||
- **Calling a method** — `MethodName();` — same method can be called any number of times, each call re-executing the body independently. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Method definition: `class Program { static void MyMethod() { // code to be executed } }`. [S1]
|
||||
- Single call: `static void Main(string[] args) { MyMethod(); }` → outputs `"I just got executed!"`. [S1]
|
||||
- Repeated calls: calling `MyMethod();` three times in `Main()` prints the same message three times. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C++와 달리 클래스 밖의 자유 함수가 존재하지 않음**: Syntax 챕터에서 확인된 "모든 코드는 class 안에" 원칙 때문에, C#은 C++처럼 클래스 밖에 독립적으로 존재하는 자유 함수를 가질 수 없고 모든 함수가 반드시 어떤 class의 메서드라는 점이 확인됨 — Main() 자체도 Program 클래스 안에 있음. [S1]
|
||||
- **변수는 소문자, 메서드는 대문자로 시작하는 명명 규칙 분리가 완성됨**: Identifiers 챕터에서 예고했던 변수 lowercase 시작 관례에 이어, 이번 챕터는 메서드명을 uppercase로 시작하도록 명시적으로 권장한다는 점이 확인됨 — 식별자 종류(변수 vs 메서드)에 따라 대소문자 관례가 갈라지는 C#만의 스타일 규칙. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — "I just got executed!"를 출력하는 메서드를 정의하고 여러 번 호출하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Minimal method definition and repeated calls (C#):
|
||||
```csharp
|
||||
static void MyMethod()
|
||||
{
|
||||
Console.WriteLine("I just got executed!");
|
||||
}
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
MyMethod();
|
||||
MyMethod();
|
||||
MyMethod();
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Arrays Multi]], [[CSharp Method Parameters]], [[CSharp Variables Identifiers]], [[CPP Functions]]
|
||||
- **참조 맥락:** Methods 섹션 — Method Parameters 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Methods — https://www.w3schools.com/cs/cs_methods.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Methods" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
id: csharp-oop
|
||||
title: "C# - What is OOP?"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["object-oriented programming C#", "DRY principle", "C# OOP 소개"]
|
||||
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", "oop"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_oop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp OOP]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Unlike Topic_C, which never had an OOP chapter at all (procedural only), and Topic_CPP, where OOP was introduced as an OPTIONAL paradigm layered on top of C-style procedural code, this C# chapter frames OOP as the language's core identity from the very first sentence — reinforcing what the Syntax chapter already forced structurally (every line of code must be inside a class): in C#, object-oriented isn't an available style choice the way it was for C++, it's the only way the language works. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Procedural vs. object-oriented** — procedural programming writes procedures/methods that operate on data; OOP creates objects that bundle BOTH data and methods together. [S1]
|
||||
- **Claimed OOP advantages** — faster/easier to execute, clearer program structure, supports the DRY principle (Don't Repeat Yourself), enables reusable applications with less code and shorter development time. [S1]
|
||||
- **DRY principle** — extract code common to the application into a single place and reuse it, instead of repeating it. [S1]
|
||||
- **Class** — a template/blueprint for creating objects. [S1]
|
||||
- **Object** — an instance of a class; created objects inherit all variables and methods from their class. [S1]
|
||||
- **Class-vs-object illustration** — `Fruit` (class) → `Apple`, `Banana`, `Mango` (objects); `Car` (class) → `Volvo`, `Audi`, `Toyota` (objects). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- No code examples in this chapter — purely conceptual, deferring class/object syntax to the next chapter. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **OOP가 선택이 아니라 언어의 본질로 제시됨**: Topic_C에는 OOP 챕터 자체가 없었고(순수 절차적 언어), Topic_CPP는 OOP를 C 스타일 절차적 코드 위에 선택적으로 얹는 패러다임으로 소개했지만, C#은 Syntax 챕터에서 이미 확인된 "모든 코드는 class 안에" 구조적 강제를 그대로 반영해 OOP를 언어의 유일한 작동 방식으로 첫 문장부터 제시한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — Fruit/Car를 class로, 그 인스턴스들을 object로 비유하는 개념 설명이 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
없음 — 이 챕터는 코드 예제가 없는 개념 소개 챕터.
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Method Parameters Return]], [[CSharp Classes]], [[CPP OOP]]
|
||||
- **참조 맥락:** OOP Basics 섹션 — Classes and Objects 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# - What is OOP? — https://www.w3schools.com/cs/cs_oop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# - What is OOP?" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: csharp-operators
|
||||
title: "C# Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["arithmetic operators 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", "arithmetic"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_operators.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The seven arithmetic operators (`+ - * / % ++ --`) and their exact symbols/semantics are unchanged across C, C++, and now C# — this chapter is the second (after Comments) where "how is C# different" has no answer at all, reinforcing that C#'s syntactic closeness to the C family is strongest at the expression-operator level and only diverges once whole-program structure (mandatory classes) or memory model (managed runtime) enters the picture. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+`** — addition; also usable to chain sums across variables (`sum2 = sum1 + 250;`). [S1]
|
||||
- **`-`** — subtraction. [S1]
|
||||
- **`*`** — multiplication. [S1]
|
||||
- **`/`** — division. [S1]
|
||||
- **`%`** — modulus (division remainder). [S1]
|
||||
- **`++`** — increment, increases a variable's value by 1. [S1]
|
||||
- **`--`** — decrement, decreases a variable's value by 1. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Direct literal addition: `int x = 100 + 50;`. [S1]
|
||||
- Chained variable addition: `int sum1 = 100 + 50; int sum2 = sum1 + 250; int sum3 = sum2 + sum2;` → 150, 400, 800. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++와 완전히 동일한 산술 연산자 집합**: `+ - * / % ++ --` 7개 연산자의 기호와 의미가 C/C++와 전혀 차이가 없다는 점이 이번 챕터에서 확인됨 — Comments 챕터에 이은 두 번째 "완전 동일" 사례. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 여러 변수를 연쇄적으로 더해 누적 합을 만드는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Chained arithmetic across variables (C#):
|
||||
```csharp
|
||||
int sum1 = 100 + 50; // 150
|
||||
int sum2 = sum1 + 250; // 400
|
||||
int sum3 = sum2 + sum2; // 800
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Operators Assignment]], [[CPP Operators Arithmetic]], [[C Operators]]
|
||||
- **참조 맥락:** Operators 섹션 — Assignment Operators 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Operators — https://www.w3schools.com/cs/cs_operators.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: csharp-operators-assignment
|
||||
title: "C# Assignment Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["+= -= *= C#", "compound assignment 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", "assignment"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_operators_assignment.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Assignment Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
All 11 compound assignment operators listed here — including the bitwise ones (`&= |= ^= >>= <<=`) — are identical in symbol and "same as" expansion to C/C++'s set, confirming that C#'s bitwise operator support (and its assignment-operator shorthand) was inherited wholesale rather than redesigned, despite C# otherwise being a managed, higher-level language than C/C++. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`=`** — basic assignment. [S1]
|
||||
- **`+= -= *= /= %=`** — arithmetic compound assignment; each `x op= y` expands to `x = x op y`. [S1]
|
||||
- **`&= |= ^=`** — bitwise AND/OR/XOR compound assignment. [S1]
|
||||
- **`>>= <<=`** — bitwise right-shift/left-shift compound assignment. [S1]
|
||||
- Every compound operator is pure shorthand — no operator introduces new semantics beyond "apply the operation, then reassign." [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic assignment: `int x = 10;`. [S1]
|
||||
- Addition assignment: `int x = 10; x += 5;` → `x` becomes 15. [S1]
|
||||
- Full expansion table: `x = 5` → `x = 5`; `x += 3` → `x = x + 3`; `x -= 3` → `x = x - 3`; `x *= 3` → `x = x * 3`; `x /= 3` → `x = x / 3`; `x %= 3` → `x = x % 3`; `x &= 3` → `x = x & 3`; `x |= 3` → `x = x | 3`; `x ^= 3` → `x = x ^ 3`; `x >>= 3` → `x = x >> 3`; `x <<= 3` → `x = x << 3`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **비트 연산 대입 연산자까지 C/C++와 동일**: `&= |= ^= >>= <<=`를 포함한 11개 대입 연산자 전체가 C/C++의 집합과 기호·확장 규칙이 동일하다는 점이 확인됨 — C#이 매니지드 런타임 위에서 동작하는 상위 언어임에도 비트 연산 지원을 그대로 계승했음을 보여줌. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — `x += 5;` 하나의 덧셈 대입 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Compound assignment shorthand — identical to C/C++ (C#):
|
||||
```csharp
|
||||
int x = 10;
|
||||
x += 5; // same as x = x + 5; -> x is now 15
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Operators]], [[CSharp Operators Comparison]], [[CPP Operators Assignment]]
|
||||
- **참조 맥락:** Operators 섹션 — Comparison Operators 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Assignment Operators — https://www.w3schools.com/cs/cs_operators_assignment.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Assignment Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
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).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: csharp-operators-logical
|
||||
title: "C# Logical Operators"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["&& || ! 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", "operators", "logical"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_operators_logical.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Logical Operators]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The three logical operators (`&&`, `||`, `!`) use the exact same symbols and short-circuit-implying descriptions ("returns True if BOTH statements are true" / "if ONE of the statements is true") as C/C++ — the only genuinely new element in this short chapter is that the operators combine `bool`-typed comparison results (themselves real `True`/`False` values, per the previous chapter) rather than C's 1/0 integer stand-ins, making a chain like `x < 5 && x < 10` operate on two authentic boolean values instead of two truthy integers. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`&&` (logical AND)** — returns `True` only if BOTH operand statements are true. [S1]
|
||||
- **`||` (logical OR)** — returns `True` if AT LEAST ONE operand statement is true. [S1]
|
||||
- **`!` (logical NOT)** — reverses the result: returns `False` if the inner expression is true (and vice versa). [S1]
|
||||
- **Combines with comparison operators** — logical operators are typically used to chain multiple comparison expressions together (e.g. `x < 5 && x < 10`). [S1]
|
||||
- **Deferred depth** — the tutorial explicitly defers deeper coverage to the upcoming Booleans and If...Else chapters. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- AND example: `x < 5 && x < 10`. [S1]
|
||||
- OR example: `x < 5 || x < 4`. [S1]
|
||||
- NOT example: `!(x < 5 && x < 10)`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **연산자 기호와 의미는 C/C++와 동일, 피연산자 타입만 실질적 bool로 확인됨**: `&& || !` 세 연산자의 기호와 논리는 C/C++와 차이가 없지만, Comparison Operators 챕터에서 확인된 것처럼 이 연산자들이 결합하는 대상이 진짜 bool 값이라는 점이 C의 정수 기반 논리 판정과의 실질적 차이로 재확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — AND/OR/NOT 각각의 최소 예제식이 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Logical AND/OR/NOT combining bool comparison results (C#):
|
||||
```csharp
|
||||
bool r1 = (x < 5 && x < 10); // AND -- both must be true
|
||||
bool r2 = (x < 5 || x < 4); // OR -- at least one must be true
|
||||
bool r3 = !(x < 5 && x < 10); // NOT -- reverses the result
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Operators Comparison]], [[CSharp Booleans]], [[CSharp Conditions]]
|
||||
- **참조 맥락:** Operators 섹션의 마지막 챕터 — Math 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Logical Operators — https://www.w3schools.com/cs/cs_operators_logical.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Logical Operators" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: csharp-output
|
||||
title: "C# Output"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Console.WriteLine", "Console.Write", "C# 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "output"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_output.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Output]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# splits what C's single `printf` handled into two separate methods differentiated ONLY by whether a trailing newline is added — `WriteLine()` (adds newline) vs. `Write()` (doesn't) — the same two-method split C++ never needed because `cout <<` never auto-newlines (you always add `"\n"` explicitly), meaning C# occupies a middle ground: less manual than C++'s explicit-newline-every-time model, but still requires picking the right method name up front rather than composing newlines as data. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`Console.WriteLine()`** — outputs text/values AND appends a new line after each call. [S1]
|
||||
- **`Console.Write()`** — outputs text/values WITHOUT appending a new line; consecutive `Write()` calls print on the same line. [S1]
|
||||
- **Numeric output & inline math** — `Console.WriteLine(3 + 3);` performs the calculation and prints the result directly, no string conversion needed. [S1]
|
||||
- **Tutorial convention** — the W3Schools C# series uses `WriteLine()` exclusively going forward, specifically because it makes output easier to read chapter-to-chapter. [S1]
|
||||
- **Manual spacing with `Write()`** — since `Write()` never inserts anything, an extra trailing space must be added manually inside the string when concatenating consecutive `Write()` outputs for readability. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Multiple `WriteLine()` calls each produce their own line: `Console.WriteLine("Hello World!"); Console.WriteLine("I am Learning C#"); Console.WriteLine("It is awesome!");`. [S1]
|
||||
- `Write()` chaining on one line: `Console.Write("Hello World! "); Console.Write("I will print on the same line.");` — note the manual trailing space in the first string. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **줄바꿈 여부로 메서드 자체가 분리됨**: C++의 `cout <<`는 줄바꿈을 절대 자동으로 넣지 않고 항상 `"\n"`을 명시적으로 붙여야 했지만, C#은 아예 WriteLine()/Write() 두 개의 다른 메서드로 나눠 줄바꿈 자동 삽입 여부를 메서드 선택 시점에 결정한다는 점이 확인됨 — C의 printf 하나로 처리하던 것을 두 메서드로 분리한 것. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 여러 줄 출력과 같은 줄 출력을 비교하는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
WriteLine vs Write — the only difference is the trailing newline (C#):
|
||||
```csharp
|
||||
Console.WriteLine("Hello World!"); // newline added automatically
|
||||
Console.WriteLine(3 + 3); // prints 6
|
||||
|
||||
Console.Write("Hello World! "); // no newline -- manual space added
|
||||
Console.Write("I will print on the same line.");
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Syntax]], [[CSharp Comments]], [[CPP Output]]
|
||||
- **참조 맥락:** Basics 섹션 — Comments 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Output — https://www.w3schools.com/cs/cs_output.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Output" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: csharp-polymorphism
|
||||
title: "C# Polymorphism"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["virtual override C#", "method overriding C#", "C# 다형성"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "polymorphism"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_polymorphism.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Polymorphism]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# requires the EXACT same two-keyword pairing already confirmed for modern C++ in Topic_CPP — `virtual` on the base class method, `override` on each derived class's replacement — and this chapter goes further than the CPP chapter did by explicitly demonstrating the FAILURE case first: without `virtual`/`override`, calling `animalSound()` through an `Animal`-typed reference to a `Pig`/`Dog` object prints the BASE class's message every time, because (per the tutorial's own explanation) same-named methods without these keywords simply aren't polymorphic at all — they're just separately-named methods that happen to share an identifier. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Polymorphism ("many forms")** — occurs among classes related by inheritance; lets a single action be performed in different ways depending on the actual object type. [S1]
|
||||
- **Without `virtual`/`override`** — same-named methods in base and derived classes do NOT achieve polymorphism; calling the method through a base-typed reference always runs the BASE class's version, regardless of the actual object's derived type. [S1]
|
||||
- **`virtual` keyword** — placed on the BASE class method to allow it to be overridden. [S1]
|
||||
- **`override` keyword** — placed on each DERIVED class's replacement method, required alongside base `virtual` to achieve true polymorphic dispatch. [S1]
|
||||
- **Base-typed reference, derived object** — `Animal myPig = new Pig();` — the variable's declared TYPE is the base class, but the actual OBJECT is the derived class; with `virtual`/`override`, the call resolves to the derived class's implementation at runtime. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Without virtual/override (the "not the output I was looking for" case): base and derived `Animal`/`Pig`/`Dog` each define their own `animalSound()`, but `Animal myPig = new Pig(); myPig.animalSound();` prints `"The animal makes a sound"` for ALL three objects, not the derived versions. [S1]
|
||||
- With virtual/override: `public virtual void animalSound()` in `Animal`, `public override void animalSound()` in `Pig` and `Dog` → `myAnimal.animalSound()` prints `"The animal makes a sound"`, `myPig.animalSound()` prints `"The pig says: wee wee"`, `myDog.animalSound()` prints `"The dog says: bow wow"` — each resolves to its OWN class's implementation. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **virtual/override 페어링이 C++와 완전히 동일**: 기반 클래스에 virtual, 파생 클래스에 override를 붙여야 다형성이 작동한다는 규칙이 Topic_CPP의 Virtual Functions 챕터(C++11의 override 키워드 포함)와 차이가 없다는 점이 확인됨. [S1]
|
||||
- **실패 사례를 먼저 보여줌으로써 virtual의 필요성을 명확히 함**: Topic_CPP의 Virtual Functions 챕터와 달리, 이번 챕터는 virtual/override 없이 먼저 실행해 "기대와 다른 출력"이 나오는 것을 보여준 뒤에야 virtual/override를 도입한다는 점이 교육적 구성의 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Animal 기반 클래스와 Pig/Dog 파생 클래스가 각각 다른 animalSound()를 구현하고, virtual/override 없이는 모두 기반 클래스 메시지만 출력되다가 virtual/override를 추가하면 각 동물 고유의 소리가 출력되는 before/after 비교가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Without vs. with virtual/override — same call site, different resolved method (C#):
|
||||
```csharp
|
||||
// Without virtual/override -- always prints base class message
|
||||
class Animal { public void animalSound() { Console.WriteLine("The animal makes a sound"); } }
|
||||
class Pig : Animal { public void animalSound() { Console.WriteLine("The pig says: wee wee"); } }
|
||||
Animal myPig1 = new Pig();
|
||||
myPig1.animalSound(); // "The animal makes a sound" -- NOT polymorphic
|
||||
|
||||
// With virtual/override -- resolves to the actual object's type
|
||||
class Animal2 { public virtual void animalSound() { Console.WriteLine("The animal makes a sound"); } }
|
||||
class Pig2 : Animal2 { public override void animalSound() { Console.WriteLine("The pig says: wee wee"); } }
|
||||
Animal2 myPig2 = new Pig2();
|
||||
myPig2.animalSound(); // "The pig says: wee wee" -- polymorphic
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Inheritance]], [[CSharp Abstract]], [[CPP Virtual Functions]], [[CPP Polymorphism]]
|
||||
- **참조 맥락:** Polymorphism & Abstract 섹션 — Abstraction 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Polymorphism — https://www.w3schools.com/cs/cs_polymorphism.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Polymorphism" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,85 @@
|
||||
---
|
||||
id: csharp-properties
|
||||
title: "C# Properties (Get and Set)"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["get set C#", "automatic properties C#", "encapsulation C#", "C# 프로퍼티"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "oop", "properties", "encapsulation"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_properties.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Properties]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This is the chapter where the `.Length`-is-a-property-not-a-method observation from way back in the Strings chapter finally gets explained: a C# property is a LANGUAGE-LEVEL construct combining a private field with `get`/`set` accessor blocks, and — unlike C++, which has no native property syntax and requires programmers to write plain `getName()`/`setName()` METHODS by convention — C# additionally offers "automatic properties" (`public string Name { get; set; }`) that need no backing field written at all, making encapsulation nearly free syntactically where C++ makes it entirely manual boilerplate. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Encapsulation** — hiding sensitive data by declaring fields `private`, then exposing controlled access through `public` get/set methods via properties. [S1]
|
||||
- **Property** — a hybrid of a variable and a method, containing a `get` accessor and a `set` accessor. [S1]
|
||||
- **`get` accessor** — returns the value of the associated private field. [S1]
|
||||
- **`set` accessor** — assigns a value to the associated private field; the special `value` keyword represents whatever value is being assigned to the property. [S1]
|
||||
- **Naming convention** — the property should share the field's name but start with an UPPERCASE letter (`name` field ↔ `Name` property). [S1]
|
||||
- **Automatic (shorthand) properties** — `public string Name { get; set; }` — no backing field declared manually; the compiler generates one implicitly, producing identical behavior with less code. [S1]
|
||||
- **Encapsulation benefits** — better control over class members, ability to make a field effectively read-only (get-only) or write-only (set-only), flexibility to change internals without breaking external code, and increased data security. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full manual property: `class Person { private string name; public string Name { get { return name; } set { name = value; } } }`. [S1]
|
||||
- Usage: `Person myObj = new Person(); myObj.Name = "Liam"; Console.WriteLine(myObj.Name);` → `"Liam"` — accessed via the SAME dot syntax as a plain field, even though a get/set pair runs underneath. [S1]
|
||||
- Automatic property equivalent: `class Person { public string Name { get; set; } }` — same usage, same output, but no explicit `name` field or accessor bodies written. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Strings 챕터의 .Length 프로퍼티 미스터리가 여기서 풀림**: Topic_CSharp의 Strings 챕터에서 `.Length`가 괄호 없는 프로퍼티라고 확인했었는데, 이번 챕터가 프로퍼티의 실제 정의(private 필드 + get/set)를 설명함으로써 그 문법적 정체가 명확해짐. [S1]
|
||||
- **C++에는 없는 언어 차원의 프로퍼티 문법**: C++는 프로퍼티라는 언어 기능이 없어 getName()/setName() 같은 일반 메서드를 관례적으로 작성해야 했지만, C#은 get/set 접근자를 언어 문법으로 제공하며 심지어 자동 프로퍼티(`{ get; set; }`)로 백킹 필드조차 생략할 수 있다는 점이 확인됨 — 캡슐화 구현 비용이 C++보다 훨씬 낮음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
Person 클래스의 private name 필드를 public Name 프로퍼티(get/set)로 감싸 외부에서 myObj.Name으로 안전하게 읽고 쓰는 예제, 그리고 이를 자동 프로퍼티로 축약한 동일 결과의 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Manual property vs. automatic (shorthand) property — same behavior (C#):
|
||||
```csharp
|
||||
// Manual
|
||||
class Person
|
||||
{
|
||||
private string name;
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set { name = value; }
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic (shorthand) -- no backing field written
|
||||
class PersonShort
|
||||
{
|
||||
public string Name { get; set; }
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Access Modifiers]], [[CSharp Strings]], [[CSharp Inheritance]], [[CPP Encapsulation]]
|
||||
- **참조 맥락:** Access Modifiers & Properties 섹션의 마지막 챕터 — Inheritance 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Properties (Get and Set) — https://www.w3schools.com/cs/cs_properties.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Properties (Get and Set)" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: csharp-strings
|
||||
title: "C# Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: [".Length property", "ToUpper ToLower", "C# 문자열"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "strings"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_strings.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# exposes string length as a PROPERTY (`txt.Length`, no parentheses) rather than a METHOD call, which is a subtle but real divergence from both C++'s `std::string::length()` (a method call with parens) and Java's `.length()` (also a method call) — the tutorial's own example (`txt.Length`) reveals that C# treats a string "as an object" but distinguishes properties (state you read) from methods (behavior you invoke, like `.ToUpper()`), a distinction C++/Java collapse into "just call a method for everything." [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **String = object with properties and methods** — unlike C's raw char arrays, a C# string is genuinely an object. [S1]
|
||||
- **`.Length` property** — no parentheses; accessed like a field, not called like a function (`txt.Length`, NOT `txt.Length()`). [S1]
|
||||
- **`.ToUpper()` / `.ToLower()`** — methods (with parentheses) that return a NEW string converted to upper/lower case, leaving the original unchanged. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic declaration: `string greeting = "Hello";` / multi-word: `string greeting2 = "Nice to meet you!";`. [S1]
|
||||
- Length: `string txt = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Console.WriteLine("The length of the txt string is: " + txt.Length);` → 26. [S1]
|
||||
- Case conversion: `string txt = "Hello World"; Console.WriteLine(txt.ToUpper()); Console.WriteLine(txt.ToLower());`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Length가 메서드가 아니라 프로퍼티임**: C++의 `std::string::length()`와 Java의 `.length()`는 둘 다 괄호를 붙여 호출하는 메서드였지만, C#의 `.Length`는 괄호 없이 필드처럼 접근하는 프로퍼티라는 점이 확인됨 — C#은 "상태를 읽는 것(프로퍼티)"과 "동작을 호출하는 것(메서드, 예: `.ToUpper()`)"을 문법적으로 구분함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 문자열 길이 출력과 대소문자 변환 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Property access (no parens) vs. method call (with parens) on a string (C#):
|
||||
```csharp
|
||||
string txt = "Hello World";
|
||||
Console.WriteLine(txt.Length); // property -- no parentheses -> 11
|
||||
Console.WriteLine(txt.ToUpper()); // method -- parentheses -> "HELLO WORLD"
|
||||
Console.WriteLine(txt.ToLower()); // method -- parentheses -> "hello world"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Strings Concat]], [[CPP Strings]], [[Java Strings]]
|
||||
- **참조 맥락:** Strings 섹션 — String Concatenation 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Strings — https://www.w3schools.com/cs/cs_strings.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: csharp-strings-access
|
||||
title: "C# Access Strings"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["IndexOf Substring", "string indexing C#", "C# 문자열 접근"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "strings", "indexing"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_strings_access.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Access Strings]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
`myString[0]` reuses the identical square-bracket index syntax from C's raw char arrays and C++'s `std::string::operator[]`, 0-indexed exactly the same way — but C# then layers `IndexOf()` and `Substring()` on top as a matched PAIR designed to work together (`name.Substring(name.IndexOf("D"))` finds a position, then slices from it), a "search then slice" combo pattern this wiki hasn't seen expressed this explicitly in C/C++ (C++'s `std::string::find()` + `substr()` do the same job but the tutorial there never demonstrated them chained as a single idiom the way this C# chapter does). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`[]` indexing** — access a single character by index, 0-based: `myString[0]` is the first character. [S1]
|
||||
- **`.IndexOf(char)`** — returns the index position of the FIRST occurrence of a specified character/substring. [S1]
|
||||
- **`.Substring(startIndex)`** — extracts and returns a NEW string starting from the given index to the end. [S1]
|
||||
- **Combined idiom: search-then-slice** — `IndexOf()` locates a position, and that position is fed directly into `Substring()` to extract everything from that point onward (e.g. isolating a last name from a full name). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic indexing: `string myString = "Hello"; Console.WriteLine(myString[0]); // "H"` and `myString[1]; // "e"`. [S1]
|
||||
- Search: `string myString = "Hello"; Console.WriteLine(myString.IndexOf("e")); // 1`. [S1]
|
||||
- Combined search+slice: `string name = "John Doe"; int charPos = name.IndexOf("D"); string lastName = name.Substring(charPos); Console.WriteLine(lastName);` → `"Doe"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **대괄호 인덱싱 문법은 C/C++와 동일**: `myString[0]`이 0부터 시작하는 인덱스로 문자에 접근하는 방식이 C 배열, C++의 `std::string::operator[]`와 차이가 없다는 점이 확인됨. [S1]
|
||||
- **IndexOf+Substring 조합 관용구가 명시적으로 제시됨**: C++도 `find()`+`substr()`로 동일한 일을 할 수 있었지만, Topic_CPP의 문자열 챕터에서는 두 메서드를 체이닝하는 관용구가 이렇게 명시적으로 다뤄지지 않았다는 점이 이번 챕터에서 새롭게 확인됨 — "찾고 나서 자르기"라는 하나의 패턴으로 제시됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
"John Doe"라는 전체 이름에서 "D"의 위치를 찾아 그 위치부터 Substring()으로 성(lastName)만 추출하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Search-then-slice idiom combining IndexOf() and Substring() (C#):
|
||||
```csharp
|
||||
string name = "John Doe";
|
||||
int charPos = name.IndexOf("D"); // find position of "D"
|
||||
string lastName = name.Substring(charPos); // slice from that position -> "Doe"
|
||||
Console.WriteLine(lastName);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Strings Interpol]], [[CSharp Strings Chars]], [[CPP Strings Access]]
|
||||
- **참조 맥락:** Strings 섹션 — Special Characters 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Access Strings — https://www.w3schools.com/cs/cs_strings_access.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Access Strings" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,72 @@
|
||||
---
|
||||
id: csharp-strings-chars
|
||||
title: "C# Special Characters"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["escape characters C#", "\\n \\t \\\" 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", "strings", "escape-characters"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_strings_chars.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Special Characters]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Every escape sequence in this chapter (`\'`, `\"`, `\\`, `\n`, `\t`, `\b`) is character-for-character identical to C and C++'s escape sequences, making this the third "zero divergence" chapter in the C# series so far (after Comments and Operators) — the pattern across all three is that C#'s LEXICAL-LEVEL syntax (tokens, literals, comments, escapes) stays fully compatible with the C family, while its STRUCTURAL rules (mandatory classes, `.Length` as property not method, `Convert.To*`) are where the real divergence happens. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Why escapes are needed** — a double quote inside a double-quoted string literal breaks parsing; C# needs a way to include one. [S1]
|
||||
- **`\'`** — inserts a single quote. [S1]
|
||||
- **`\"`** — inserts a double quote. [S1]
|
||||
- **`\\`** — inserts a single backslash. [S1]
|
||||
- **`\n`** — new line. [S1]
|
||||
- **`\t`** — tab. [S1]
|
||||
- **`\b`** — backspace. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Broken (unescaped) example shown deliberately as an error case: `string txt = "We are the so-called "Vikings" from the north.";` — the tutorial shows this fails, then fixes it with `\"`. [S1]
|
||||
- Fixed: `string txt = "We are the so-called \"Vikings\" from the north.";`. [S1]
|
||||
- Single quote escape: `string txt = "It\'s alright.";`. [S1]
|
||||
- Backslash escape: `string txt = "The character \\ is called backslash.";`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **이스케이프 시퀀스가 C/C++와 완전히 동일**: `\' \" \\ \n \t \b` 전부 C/C++와 기호·의미가 동일하다는 점이 확인됨 — Comments, Operators에 이은 세 번째 "완전 동일" 챕터. 이는 C#의 어휘 수준 문법(토큰/리터럴/주석/이스케이프)이 C 계열과 완전히 호환되는 반면, 구조적 규칙(클래스 강제, .Length 프로퍼티, Convert.To* 등)에서만 실질적으로 갈라진다는 패턴을 보여줌. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 큰따옴표/작은따옴표/백슬래시를 이스케이프해 문자열에 포함시키는 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Escape sequences — identical to C/C++ (C#):
|
||||
```csharp
|
||||
string txt1 = "We are the so-called \"Vikings\" from the north.";
|
||||
string txt2 = "It\'s alright.";
|
||||
string txt3 = "The character \\ is called backslash.";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Strings Access]], [[CSharp Booleans]], [[CPP Strings Esc]]
|
||||
- **참조 맥락:** Strings 섹션의 마지막 챕터 — Booleans 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Special Characters — https://www.w3schools.com/cs/cs_strings_chars.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Special Characters" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
id: csharp-strings-concat
|
||||
title: "C# String Concatenation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["string.Concat", "+ operator strings C#", "C# 문자열 연결"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "strings", "concatenation"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_strings_concat.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp String Concatenation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter's own explicit "WARNING!" — that `+` means addition for numbers but concatenation for strings — is the exact ambiguity already flagged conceptually in the Display Variables chapter, but now the tutorial adds a SECOND, unambiguous alternative (`string.Concat(firstName, lastName)`) that sidesteps the `+` overload entirely, giving C# two genuinely different concatenation mechanisms (operator overload vs. static method call) where C++ effectively only has the operator-overload route (`std::string::operator+`) and C has neither (manual `strcat`/buffer management). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+` for concatenation** — `firstName + lastName` combines two strings; manual spacing must be added inside the literal (`"John "` with a trailing space) since concatenation never auto-inserts spaces. [S1]
|
||||
- **`string.Concat()`** — a static method alternative that concatenates two strings without relying on operator overloading: `string.Concat(firstName, lastName)`. [S1]
|
||||
- **`+` ambiguity (explicit warning)** — numbers ADD, strings CONCATENATE, using the identical `+` symbol; the tutorial calls this out with a dedicated "WARNING!" callout box. [S1]
|
||||
- **Same-symbol, different-type example** — `int z = x + y;` (numeric, x=10 int, y=20 int) → `30`; `string z = x + y;` (x="10" string, y="20" string) → `"1020"`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Operator concatenation: `string firstName = "John "; string lastName = "Doe"; string name = firstName + lastName; Console.WriteLine(name);` → `"John Doe"`. [S1]
|
||||
- Method concatenation: `string name = string.Concat(firstName, lastName);` — same result via a different mechanism. [S1]
|
||||
- Numeric vs. string `+` side-by-side: `int x = 10; int y = 20; int z = x + y; // 30` versus `string x = "10"; string y = "20"; string z = x + y; // "1020"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **연결 방식이 두 개로 이중화됨**: C++는 사실상 `std::string`의 `+` 연산자 오버로드 하나에 의존했고 C는 아예 연산자가 없어 `strcat` 등을 수동으로 써야 했지만, C#은 `+` 연산자 오버로드와 `string.Concat()` 정적 메서드라는 두 가지 독립된 문자열 연결 방식을 제공한다는 점이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
동일한 firstName/lastName 두 변수를 `+`와 `string.Concat()` 두 가지 방식으로 각각 연결하는 비교 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Two independent concatenation mechanisms — operator overload vs. static method (C#):
|
||||
```csharp
|
||||
string firstName = "John ";
|
||||
string lastName = "Doe";
|
||||
|
||||
string name1 = firstName + lastName; // operator overload
|
||||
string name2 = string.Concat(firstName, lastName); // static method -- same result
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Strings]], [[CSharp Strings Interpol]], [[CSharp Variables Display]]
|
||||
- **참조 맥락:** Strings 섹션 — String Interpolation 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# String Concatenation — https://www.w3schools.com/cs/cs_strings_concat.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# String Concatenation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
id: csharp-strings-interpol
|
||||
title: "C# String Interpolation"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["$ string C#", "interpolated strings", "C# 문자열 보간"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "strings", "interpolation"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_strings_interpol.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp String Interpolation]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s `$"...{var}..."` interpolated strings (introduced in C# 6) solve the exact same "embed a variable directly in text without manual concatenation" problem that Python's f-strings (`f"...{var}..."`) already solved in this wiki series — same `{}` placeholder mechanism, just a `$` prefix instead of Python's `f` prefix — while C++ still has no first-class equivalent (requiring `std::format` in C++20+ or manual `<<` chaining), making C# the second language in this series (after Python) to bake variable-embedding directly into string literal syntax rather than relying purely on the `+` operator. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`$` prefix** — required to enable string interpolation; without it, `{firstName}` would just be literal text, not a placeholder. [S1]
|
||||
- **`{variable}` placeholders** — variable names inside curly braces are substituted with their values directly in the string. [S1]
|
||||
- **No manual spacing needed** — unlike `+` concatenation (which required manually adding a trailing space inside `"John "`), interpolation lets you place spaces naturally between placeholders in the template string. [S1]
|
||||
- **Introduced in C# 6** — a relatively recent addition to the language, not present from C#'s first version. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Example: `string firstName = "John"; string lastName = "Doe"; string name = $"My full name is: {firstName} {lastName}"; Console.WriteLine(name);` → `"My full name is: John Doe"`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Python의 f-string과 동일한 설계 철학**: `$"...{var}..."`의 `{}` 플레이스홀더 치환 방식이 이전에 위키화한 Topic_Python의 f-string(`f"...{var}..."`)과 접두사 문자만 다를 뿐 동일한 메커니즘이라는 점이 확인됨 — C++는 이 시리즈에서 아직 이런 1급 문자열 보간 문법을 갖추지 못했음(C++20의 std::format 이전까지는 없었음). [S1]
|
||||
- **공백을 수동으로 넣을 필요가 없어짐**: String Concatenation 챕터의 `+` 방식은 `"John "`처럼 문자열 리터럴 안에 공백을 미리 넣어둬야 했지만, 보간 문자열은 템플릿 안에서 자연스럽게 공백을 배치할 수 있다는 점이 개선점으로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
firstName과 lastName을 `$"My full name is: {firstName} {lastName}"` 형태로 한 줄에 합쳐 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
String interpolation with the `$` prefix — no manual spacing needed (C#):
|
||||
```csharp
|
||||
string firstName = "John";
|
||||
string lastName = "Doe";
|
||||
string name = $"My full name is: {firstName} {lastName}";
|
||||
Console.WriteLine(name); // "My full name is: John Doe"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Strings Concat]], [[CSharp Strings Access]], [[Python F Strings]]
|
||||
- **참조 맥락:** Strings 섹션 — Access Strings 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# String Interpolation — https://www.w3schools.com/cs/cs_strings_interpol.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# String Interpolation" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: csharp-switch
|
||||
title: "C# Switch"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["switch case break default 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", "switch"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_switch.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Switch]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
The `switch(expression) { case x: ... break; default: ... break; }` skeleton is structurally identical to C/C++'s switch statement — same `case`/`break`/`default` keywords, same "evaluate once, compare against each case" model — making Switch the fourth chapter in the C# series (after Comments, Operators, Special Characters) where the answer to "what's different from C++" is essentially nothing at the syntax level shown here. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`switch(expression)`** — evaluated exactly ONCE, then compared against each `case` value in order. [S1]
|
||||
- **`case x:`** — if the switch expression matches `x`, that block's code runs. [S1]
|
||||
- **`break`** — exits the switch block immediately once a match's code has run, preventing execution from continuing into subsequent cases; described as saving execution time by skipping the rest of the block. [S1]
|
||||
- **`default:`** — optional; runs when NO case matches the expression. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Weekday-name example: `switch (day) { case 1: Console.WriteLine("Monday"); break; ... case 7: Console.WriteLine("Sunday"); break; }` with `day = 4` → outputs `"Thursday"`. [S1]
|
||||
- Default fallback example: `switch (day) { case 6: ...Saturday...; break; case 7: ...Sunday...; break; default: Console.WriteLine("Looking forward to the Weekend."); break; }` with `day = 4` (no matching case) → outputs `"Looking forward to the Weekend."` via `default`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **switch 구조가 C/C++와 동일**: `switch`/`case`/`break`/`default` 키워드와 전체 구조가 C/C++의 switch문과 차이가 없다는 점이 확인됨 — Comments, Operators, Special Characters에 이은 네 번째 "구조 동일" 챕터. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
요일 번호(day)를 받아 요일 이름을 출력하는 switch문과, 매치되는 case가 없을 때 default로 넘어가는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Switch with break and default (C#):
|
||||
```csharp
|
||||
int day = 4;
|
||||
switch (day)
|
||||
{
|
||||
case 1:
|
||||
Console.WriteLine("Monday");
|
||||
break;
|
||||
case 4:
|
||||
Console.WriteLine("Thursday");
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Looking forward to the Weekend.");
|
||||
break;
|
||||
}
|
||||
// Outputs "Thursday"
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.82
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Conditions Shorthand]], [[CSharp While Loop]], [[CPP Switch]]
|
||||
- **참조 맥락:** Switch 섹션의 유일 챕터 — Loops 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Switch — https://www.w3schools.com/cs/cs_switch.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Switch" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
id: csharp-syntax
|
||||
title: "C# Syntax"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["using System", "namespace class Main", "C# 문법"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.86
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "syntax"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_syntax.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Syntax]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# mandates that EVERY line of executable code live inside a `class` — there is no C-style bare top-level `int main()`, no C++-style free function outside any class — which means C#'s minimal program has a mandatory extra nesting layer (`namespace` → `class` → `Main` method) that neither C nor C++ required, and the tutorial explicitly flags one specific Java-vs-C# difference unprompted: unlike Java, the C# filename does NOT have to match the class name (even though convention usually makes them match anyway). [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`using System;`** — imports the System namespace, enabling unqualified use of its classes (e.g. `Console` instead of `System.Console`). [S1]
|
||||
- **`namespace`** — a container for classes and other namespaces, used to organize code. [S1]
|
||||
- **`class`** — a container for data and methods; ALL executable C# code must be inside a class, with no exception (unlike C's free-standing `main()` or C++'s optional free functions). [S1]
|
||||
- **Curly braces `{}`** — mark the beginning/end of every code block (namespace body, class body, method body). [S1]
|
||||
- **`Main` method** — the entry point; code inside its braces is what actually executes when the program runs. [S1]
|
||||
- **`Console.WriteLine()`** — a method of the `Console` class (part of the `System` namespace) used to print text; omitting `using System;` requires the fully-qualified `System.Console.WriteLine()` instead. [S1]
|
||||
- **Semicolons mandatory** — every C# statement ends with `;`. [S1]
|
||||
- **Case-sensitivity** — `MyClass` and `myclass` are distinct identifiers. [S1]
|
||||
- **Filename vs. class name** — unlike Java (where the public class name MUST match the filename), C# does not enforce this; matching them is convention only, and the saved file must end in `.cs`. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Full annotated example, line by line: `using System;` (namespace import) → blank line (ignored whitespace, used for readability) → `namespace HelloWorld` (organizational container) → `{` (block start) → `class Program` (mandatory class wrapper) → `static void Main(string[] args)` (entry point, keywords deferred to later chapters) → `Console.WriteLine("Hello World!");` (the actual output statement). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **모든 실행 코드가 반드시 class 안에 있어야 함**: C는 최상위 함수(`int main()`)를, C++는 클래스 밖의 자유 함수(free function)도 허용했지만, C#은 실행되는 모든 코드 줄이 반드시 class 내부에 있어야 한다는 제약이 명시적으로 확인됨 — namespace→class→Main이라는 필수 3중 중첩 구조. [S1]
|
||||
- **파일명과 클래스명 일치가 Java와 달리 강제되지 않음**: 원문이 직접 "Unlike Java, the name of the C# file does not have to match the class name"이라고 명시 — Java는 public 클래스명과 파일명이 반드시 일치해야 하는 반면, C#은 관례일 뿐 강제 규칙이 아님이 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
이전 챕터(Get Started)에서 등장한 동일한 Hello World 보일러플레이트를 한 줄씩 분해 설명하는 것이 이번 챕터의 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Minimal C# program structure — namespace/class/Main nesting is mandatory (C#):
|
||||
```csharp
|
||||
using System;
|
||||
namespace HelloWorld
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.86
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Get Started]], [[CSharp Output]], [[Java Intro]], [[CPP Namespaces]]
|
||||
- **참조 맥락:** Basics 섹션 — Output 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Syntax — https://www.w3schools.com/cs/cs_syntax.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Syntax" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: csharp-type-casting
|
||||
title: "C# Type Casting"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["implicit explicit casting C#", "Convert.ToInt32", "C# 형변환"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "type-casting"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_type_casting.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Type Casting]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s explicit-cast syntax `(int) myDouble` is character-for-character identical to C and C++'s C-style cast, but C# adds an entire SECOND casting mechanism the C family never had — the `Convert.ToXxx()` static method family (`Convert.ToInt32`, `Convert.ToString`, `Convert.ToBoolean`, `Convert.ToDouble`) — meaning C# programmers have two genuinely different ways to convert types (parenthesis-cast for numeric truncation, `Convert.To*` for cross-type conversions including bool/string) where C/C++ programmers had to rely on parenthesis-casts plus manual `sprintf`/`atoi`-style functions for anything beyond numeric types. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Implicit casting (automatic)** — converting a SMALLER type to a LARGER type happens automatically, no syntax needed: `char → int → long → float → double`. [S1]
|
||||
- **Explicit casting (manual)** — converting a LARGER type to a SMALLER type requires an explicit cast written as `(type) value` in front of the value: `double → float → long → int → char`. [S1]
|
||||
- **Explicit casting truncates, doesn't round** — casting `9.78` (double) to `int` produces `9`, not `10` — the decimal part is simply dropped. [S1]
|
||||
- **`Convert.ToXxx()` methods** — a separate, non-parenthesis-cast conversion mechanism: `Convert.ToBoolean`, `Convert.ToDouble`, `Convert.ToString`, `Convert.ToInt32` (int), `Convert.ToInt64` (long) — notably covers conversions parenthesis-casts can't do directly, like bool↔string. [S1]
|
||||
- **Motivating use case (deferred)** — the tutorial explicitly points to the NEXT chapter (User Input) as the place where type conversion becomes genuinely necessary, since console input always arrives as a string. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Implicit example: `int myInt = 9; double myDouble = myInt; // Automatic casting: int to double` — both `myInt` (9) and `myDouble` (9) print identically. [S1]
|
||||
- Explicit example: `double myDouble = 9.78; int myInt = (int) myDouble; // Manual casting: double to int` — `myDouble` stays `9.78`, `myInt` becomes `9` (truncated, not rounded). [S1]
|
||||
- Convert methods example: `Console.WriteLine(Convert.ToString(myInt)); Console.WriteLine(Convert.ToDouble(myInt)); Console.WriteLine(Convert.ToInt32(myDouble)); Console.WriteLine(Convert.ToString(myBool));`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C-style 괄호 캐스팅과 완전히 동일한 구문이 유지됨**: `(int) myDouble`이라는 명시적 캐스팅 문법이 C/C++의 괄호 캐스팅과 글자 하나 다르지 않게 동일하다는 점이 확인됨. [S1]
|
||||
- **Convert.ToXxx()라는 C/C++에 없던 완전히 별도의 변환 체계가 추가됨**: C/C++는 괄호 캐스팅 외에 bool↔string 같은 이종 타입 변환을 위해 각자 다른 라이브러리 함수(sprintf, atoi 등)를 조합해야 했지만, C#은 Convert 클래스의 정적 메서드 하나로 통일된 변환 인터페이스를 제공한다는 점이 새로운 차이로 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
int/double/bool 값을 Convert.ToString/ToDouble/ToInt32로 상호 변환하는 예제가 원문에서 직접 실전 활용 사례로 제시되며, "왜 변환이 필요한가"에 대해 다음 챕터(User Input)를 명시적으로 예고함. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Explicit cast (truncates) vs. Convert.ToXxx() methods (C#):
|
||||
```csharp
|
||||
double myDouble = 9.78;
|
||||
int myInt = (int) myDouble; // explicit cast -> 9 (truncated, not rounded)
|
||||
|
||||
int a = 10;
|
||||
Console.WriteLine(Convert.ToString(a)); // int to string
|
||||
Console.WriteLine(Convert.ToDouble(a)); // int to double
|
||||
bool b = true;
|
||||
Console.WriteLine(Convert.ToString(b)); // bool to string
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Data Types]], [[CSharp User Input]], [[CPP Type Casting]]
|
||||
- **참조 맥락:** Data Types & Type Casting 섹션의 마지막 챕터 — Operators 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Type Casting — https://www.w3schools.com/cs/cs_type_casting.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Type Casting" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: csharp-user-input
|
||||
title: "C# User Input"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["Console.ReadLine", "C# 사용자 입력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "user-input"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_user_input.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp User Input]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
This chapter is the exact payoff the Type Casting chapter promised — "take a look at the next chapter, when working with user input, to see an example of this [conversion]" — and it delivers precisely that: `Console.ReadLine()` ALWAYS returns a `string`, full stop, unlike C++'s `cin >>` or C's `scanf()` which can read directly into a typed variable (`int`, `double`, etc.); trying `int age = Console.ReadLine();` is a compile error ("Cannot implicitly convert type 'string' to 'int'"), forcing every numeric input in C# through an explicit `Convert.ToInt32()` (or similar) call, with a runtime `System.FormatException` risk if the user types non-numeric text — a failure mode C's `scanf()` doesn't raise as an exception (it silently fails to parse) and C++'s `cin >>` handles via the stream-error-state mechanism already documented in `[[CPP Input Validation]]`. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`Console.ReadLine()`** — reads a line of keyboard input and returns it as a `string`; the counterpart to `Console.WriteLine()`. [S1]
|
||||
- **Always returns `string`** — there is no direct "read an int" or "read a double" variant; every input arrives as text first. [S1]
|
||||
- **Implicit conversion is illegal** — `int age = Console.ReadLine();` fails at compile time with "Cannot implicitly convert type 'string' to 'int'". [S1]
|
||||
- **`Convert.ToInt32()` (and siblings)** — the explicit conversion method required to turn the string input into a usable numeric type, directly reusing the `Convert.To*` family from the Type Casting chapter. [S1]
|
||||
- **Runtime parse failure** — if the user enters non-numeric text where a number is expected, `Convert.ToInt32()` throws a `System.FormatException` ("Input string was not in a correct format.") — a RUNTIME exception, not a compile error; full handling deferred to a later Exceptions chapter. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Basic string input: `Console.WriteLine("Enter username:"); string userName = Console.ReadLine(); Console.WriteLine("Username is: " + userName);`. [S1]
|
||||
- Failing numeric input attempt: `Console.WriteLine("Enter your age:"); int age = Console.ReadLine(); Console.WriteLine("Your age is: " + age);` → compile error. [S1]
|
||||
- Fixed with explicit conversion: `Console.WriteLine("Enter your age:"); int age = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Your age is: " + age);`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **Type Casting 챕터의 예고가 이 챕터에서 실현됨**: Type Casting 챕터가 "다음 챕터(사용자 입력)에서 왜 변환이 필요한지 확인하라"고 예고했는데, 이번 챕터가 정확히 그 이유(ReadLine()이 항상 string만 반환)와 해결책(Convert.ToInt32())을 보여준다는 점이 확인됨. [S1]
|
||||
- **C/C++의 typed 입력과 달리 항상 string으로만 들어옴**: C의 scanf()나 C++의 cin >>는 변수 타입에 맞춰 직접 파싱해 읽을 수 있었지만, C#의 Console.ReadLine()은 항상 string만 반환하므로 숫자가 필요하면 반드시 Convert.ToInt32() 같은 명시적 변환을 거쳐야 한다는 점이 확인됨 — 컴파일 타임 에러(암묵적 변환 금지)로 이를 강제함. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
사용자로부터 나이를 입력받아 Convert.ToInt32(Console.ReadLine())으로 정수로 변환한 뒤 출력하는 예제가 원문에서 직접 실전 활용 사례로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Console.ReadLine() always returns string — explicit conversion required for numbers (C#):
|
||||
```csharp
|
||||
Console.WriteLine("Enter your age:");
|
||||
int age = Convert.ToInt32(Console.ReadLine()); // explicit conversion required
|
||||
Console.WriteLine("Your age is: " + age);
|
||||
// Non-numeric input throws System.FormatException at runtime
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Type Casting]], [[CSharp Enums]], [[CSharp Exceptions]], [[CPP Input Validation]]
|
||||
- **참조 맥락:** User Input 섹션의 유일 챕터 — Exceptions 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# User Input — https://www.w3schools.com/cs/cs_user_input.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# User Input" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,75 @@
|
||||
---
|
||||
id: csharp-variables
|
||||
title: "C# Variables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["int double char string bool", "C# 변수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.85
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "variables"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_variables.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Variables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s five introductory types (int/double/char/string/bool) match Java's primitive-plus-String lineup almost exactly, but `string` in C# is a genuine built-in keyword-level type from the very first variable chapter — no separate library import, no `<string>` header, no `std::string` namespace qualifier — collapsing what took C an entire "no native strings" caveat and C++ a dedicated Strings section (`<string>` header, `std::string` vs C-style char arrays) into a single bullet point alongside int/double/char/bool. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`int`** — whole numbers without decimals (e.g. `123`, `-123`). [S1]
|
||||
- **`double`** — floating-point numbers with decimals (e.g. `19.99`, `-19.99`). [S1]
|
||||
- **`char`** — a single character, surrounded by SINGLE quotes (`'a'`). [S1]
|
||||
- **`string`** — text, surrounded by DOUBLE quotes (`"Hello World"`) — a first-class type from the start, not a library add-on. [S1]
|
||||
- **`bool`** — two states only: `true` or `false`. [S1]
|
||||
- **Declaration syntax** — `type variableName = value;`; can also declare without initializing, then assign later (`int myNum; myNum = 15;`). [S1]
|
||||
- **Reassignment overwrites** — assigning a new value to an existing variable replaces the old one silently (no warning). [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- String declaration + print: `string name = "John"; Console.WriteLine(name);`. [S1]
|
||||
- Int declaration + print: `int myNum = 15; Console.WriteLine(myNum);`. [S1]
|
||||
- Declare-then-assign: `int myNum; myNum = 15; Console.WriteLine(myNum);`. [S1]
|
||||
- Overwrite: `int myNum = 15; myNum = 20; // myNum is now 20`. [S1]
|
||||
- All five types declared together: `int myNum = 5; double myDoubleNum = 5.99D; char myLetter = 'D'; bool myBool = true; string myText = "Hello";` — note the `D` suffix on the double literal. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **string이 처음부터 내장 타입으로 취급됨**: C는 문자열이라는 내장 타입 자체가 없어 char 배열로 흉내내야 했고, C++는 `<string>` 헤더와 `std::string`을 별도로 배워야 했지만, C#은 첫 변수 챕터부터 int/double/char/bool과 동일한 급으로 string을 나열한다는 점이 확인됨 — 별도 import나 네임스페이스 한정자 없이 바로 사용 가능. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — name(string)과 myNum(int) 변수를 선언하고 출력하는 기본 예제가 원문에서 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Declaring all five basic C# types (C#):
|
||||
```csharp
|
||||
int myNum = 5;
|
||||
double myDoubleNum = 5.99D;
|
||||
char myLetter = 'D';
|
||||
bool myBool = true;
|
||||
string myText = "Hello";
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.85
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables Identifiers]], [[CSharp Data Types]], [[CPP Strings]], [[C Strings]]
|
||||
- **참조 맥락:** Variables 섹션 — Identifiers 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Variables — https://www.w3schools.com/cs/cs_variables.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,65 @@
|
||||
---
|
||||
id: csharp-variables-constants
|
||||
title: "C# Constants"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["const keyword C#", "C# 상수"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "constants"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_variables_constants.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Constants]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s `const` keyword is placed BEFORE the type (`const int myNum = 15;`), exactly mirroring C's `const int` and C++'s identical placement — but C# adds a strictness neither predecessor enforces at the same chapter level: a `const` MUST be initialized at declaration, with no separate "declare now, assign later" escape hatch, producing a hard compiler error ("A const field requires a value to be provided") rather than the vaguer undefined/uninitialized-value risk C's const-without-init could silently create. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`const` keyword** — placed before the variable type, makes the variable unchangeable and read-only after its initial assignment. [S1]
|
||||
- **Mandatory initialization** — a `const` MUST be assigned a value at the point of declaration; declaring one without a value is a compile error. [S1]
|
||||
- **Use case** — values that should never change, like PI (3.14159...), protecting code from accidental overwrites by the same or other developers. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Declaration + illegal reassignment: `const int myNum = 15; myNum = 20; // error`. [S1]
|
||||
- Explicit error message quoted from the compiler: "A const field requires a value to be provided" when a const is declared without a value. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **초기화 없는 const 선언이 하드 에러로 즉시 차단됨**: C의 `const int x;`는 선언 자체는 허용되고 이후 대입이 불가능해 초기화되지 않은 값이 남는 위험이 있었지만, C#은 초기화 없는 const 선언 자체를 컴파일 에러로 명시적으로 차단한다는 점이 이번 챕터에서 확인됨. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — PI처럼 절대 변하지 않아야 하는 값의 예시로 const 사용이 원문에서 언급됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
const requires initialization at declaration — no exceptions (C#):
|
||||
```csharp
|
||||
const int myNum = 15;
|
||||
myNum = 20; // error - cannot assign to a const variable
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables Identifiers]], [[CSharp Variables Display]], [[C Constants]]
|
||||
- **참조 맥락:** Variables 섹션 — Display Variables 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Constants — https://www.w3schools.com/cs/cs_variables_constants.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Constants" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,71 @@
|
||||
---
|
||||
id: csharp-variables-display
|
||||
title: "C# Display Variables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["string concatenation C#", "+ operator overload C#", "C# 변수 출력"]
|
||||
duplicate_of: ""
|
||||
source_trust_level: "B"
|
||||
confidence_score: 0.84
|
||||
created_at: 2026-07-04
|
||||
updated_at: 2026-07-04
|
||||
review_reason: ""
|
||||
merge_history: []
|
||||
tags: ["csharp", "programming-language", "w3schools", "variables", "concatenation"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_variables_display.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Display Variables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C# overloads the SAME `+` operator to mean two entirely different operations depending on operand type — string concatenation (`"Hello " + name`) versus numeric addition (`x + y`) — with no separate concatenation operator like C++ chose to avoid (C++ ALSO overloads `<<` for output but keeps `+` mostly numeric for its native strings, relying on `std::string`'s own `+` overload); C# instead makes this dual-meaning `+` a first-class, chapter-one-visible feature, closer to Java's identical `+`-for-both-jobs design than to C++'s more type-segregated approach. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`+` for string + text combination** — `"Hello " + name` concatenates a string literal and a string variable. [S1]
|
||||
- **`+` for string + string combination** — `firstName + lastName` concatenates two string variables into a new string. [S1]
|
||||
- **`+` for numeric addition** — when both operands are numeric (e.g. `int`), `+` performs mathematical addition instead of concatenation. [S1]
|
||||
- **Type determines behavior** — the SAME operator symbol resolves to concatenation or addition purely based on the operand types involved. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- String + variable: `string name = "John"; Console.WriteLine("Hello " + name);`. [S1]
|
||||
- Variable + variable (string): `string firstName = "John "; string lastName = "Doe"; string fullName = firstName + lastName; Console.WriteLine(fullName);`. [S1]
|
||||
- Numeric addition: `int x = 5; int y = 6; Console.WriteLine(x + y); // Print the value of x + y` → outputs `11`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **동일 연산자가 타입에 따라 완전히 다른 동작을 함**: `+`가 문자열이면 연결(concatenation), 숫자면 산술 덧셈이라는 이중 역할을 한다는 점이 이번 챕터에서 확인됨 — Java와 동일한 설계이며, C++가 `std::string`의 `+` 연산자 오버로드를 통해 유사하게 동작하지만 C#은 이를 변수 출력 챕터 초반부터 명시적으로 강조한다는 차이가 있음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — 이름 문자열을 인사말과 연결하고, 숫자 두 개를 더해 출력하는 두 예제가 원문에서 나란히 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
The `+` operator's dual meaning — concatenation vs. addition (C#):
|
||||
```csharp
|
||||
string name = "John";
|
||||
Console.WriteLine("Hello " + name); // concatenation -> "Hello John"
|
||||
|
||||
int x = 5;
|
||||
int y = 6;
|
||||
Console.WriteLine(x + y); // addition -> 11
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.84
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables Constants]], [[CSharp Variables Multiple]], [[CSharp Strings Concat]]
|
||||
- **참조 맥락:** Variables 섹션 — Multiple Variables 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Display Variables — https://www.w3schools.com/cs/cs_variables_display.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Display Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: csharp-variables-identifiers
|
||||
title: "C# Identifiers"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["variable naming rules 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", "identifiers", "naming"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_variables_identifiers.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Identifiers]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
C#'s identifier rules (letters/digits/underscore, must start with letter/underscore, case-sensitive, no reserved words) are the same rule-set every C-family language in this series has used verbatim — the interesting detail isn't the rule itself but the STYLE convention layered on top: C# explicitly recommends lowercase-starting names (camelCase, e.g. `minutesPerHour`), which will matter later when C#'s method/class names are shown starting with an UPPERCASE letter (PascalCase) — a naming-convention split by identifier kind that C and C++ never enforced this explicitly. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Identifier** — the unique name given to a variable. [S1]
|
||||
- **Character rules** — letters, digits, and underscore (`_`) allowed; must begin with a letter or underscore (never a digit). [S1]
|
||||
- **Case sensitivity** — `myVar` and `myvar` are distinct variables. [S1]
|
||||
- **No whitespace** — names cannot contain spaces. [S1]
|
||||
- **No reserved words** — C# keywords like `int` or `double` cannot be used as identifier names. [S1]
|
||||
- **Style convention (recommended, not enforced)** — start with a lowercase letter; prefer descriptive names (`minutesPerHour`) over terse ones (`m`) for readability and maintainability. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Good vs. acceptable naming contrast: `int minutesPerHour = 60; // Good` vs `int m = 60; // OK, but not so easy to understand`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **명명 규칙 자체는 C/C++/Java와 동일**: 문자/숫자/언더스코어, 숫자로 시작 불가, 대소문자 구분, 예약어 사용 불가라는 규칙이 이전 언어들과 동일함이 확인됨 — 차이는 규칙이 아니라 스타일 권장(lowercase 시작, 서술적 이름 선호)에 있음. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — minutesPerHour vs m 이름 비교가 원문에서 스타일 예제로 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Descriptive vs. terse identifier naming (C#):
|
||||
```csharp
|
||||
// Good
|
||||
int minutesPerHour = 60;
|
||||
// OK, but not so easy to understand what m actually is
|
||||
int m = 60;
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables]], [[CSharp Variables Constants]]
|
||||
- **참조 맥락:** Variables 섹션 — Constants 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Identifiers — https://www.w3schools.com/cs/cs_variables_identifiers.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Identifiers" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,69 @@
|
||||
---
|
||||
id: csharp-variables-multiple
|
||||
title: "C# Multiple Variables"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["comma-separated declaration C#", "chained assignment 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", "variables"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_variables_multiple.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp Multiple Variables]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Both declaration patterns shown here — comma-separated same-type declaration (`int x = 5, y = 6, z = 50;`) and chained assignment (`x = y = z = 50;`) — are syntactically identical to C's and C++'s equivalent patterns, confirming that at the "declaring several variables at once" level, C# hasn't diverged from its C-family ancestors at all; the only C#-specific detail is that the chained-assignment form requires the variables to already be declared (`int x, y, z;` first), since C# doesn't allow declaring types mid-chain the way a single `int x = y = z = 50;` might ambiguously suggest. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **Comma-separated declaration** — `int x = 5, y = 6, z = 50;` declares three variables of the SAME type in one statement, each with its own initial value. [S1]
|
||||
- **Chained assignment** — `int x, y, z; x = y = z = 50;` declares three variables first, then assigns the SAME value to all three in one statement (evaluated right-to-left). [S1]
|
||||
- Both patterns are restricted to variables of the same declared type — no mixing types in either the comma list or the assignment chain. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- Comma-separated with individual values: `int x = 5, y = 6, z = 50; Console.WriteLine(x + y + z);` → outputs `61`. [S1]
|
||||
- Chained same-value assignment: `int x, y, z; x = y = z = 50; Console.WriteLine(x + y + z);` → outputs `150`. [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **C/C++와 동일한 두 패턴이 그대로 유지됨**: 콤마로 구분한 동시 선언과 연쇄 대입 두 패턴 모두 C/C++에서 이미 확인된 문법과 차이가 없다는 점이 이번 챕터에서 확인됨 — C#이 변수 선언 수준에서는 C 계열 문법을 그대로 계승하고 있음을 보여주는 사례. [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
현재 발견된 실제 적용 사례가 없습니다 — x+y+z를 출력하는 두 가지 선언 방식(개별 값 vs 동일 값)이 원문에서 나란히 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
Comma-separated declaration vs. chained assignment (C#):
|
||||
```csharp
|
||||
int x = 5, y = 6, z = 50;
|
||||
Console.WriteLine(x + y + z); // 61
|
||||
|
||||
int a, b, c;
|
||||
a = b = c = 50;
|
||||
Console.WriteLine(a + b + c); // 150
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Variables Display]], [[CSharp Data Types]], [[C Variables Multiple]]
|
||||
- **참조 맥락:** Variables 섹션의 마지막 챕터 — Data Types & Type Casting 섹션으로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# Multiple Variables — https://www.w3schools.com/cs/cs_variables_multiple.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# Multiple Variables" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
id: csharp-while-loop
|
||||
title: "C# While Loop"
|
||||
category: "Programming_Language"
|
||||
status: "draft"
|
||||
verification_status: "conceptual"
|
||||
canonical_id: ""
|
||||
aliases: ["do while loop C#", "C# while 반복문"]
|
||||
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", "loops", "while"]
|
||||
raw_sources: ["https://www.w3schools.com/cs/cs_while_loop.php"]
|
||||
applied_in: []
|
||||
github_commit: ""
|
||||
---
|
||||
|
||||
# [[CSharp While Loop]]
|
||||
|
||||
## 🎯 한 줄 통찰 (One-line insight)
|
||||
Both loop syntaxes on this page (`while (condition) {...}` and `do {...} while (condition);`) are identical to C/C++, and the source combines them into ONE chapter rather than splitting them across two — a structural choice that differs from Topic_CPP, where While Loop and Do While Loop were separate documents — meaning this single C# doc intentionally covers both variants together, matching the source page's own organization instead of forcing a 1:1 split that the source doesn't have. [S1]
|
||||
|
||||
## 🧠 핵심 개념 (Core concepts)
|
||||
- **`while (condition) { ... }`** — repeats the block as long as `condition` stays `True`; the condition is checked BEFORE each iteration, so the body may run zero times. [S1]
|
||||
- **`do { ... } while (condition);`** — the do/while variant; the block runs ONCE FIRST, then the condition is checked — meaning the body always executes at least once, even if the condition is false from the start. [S1]
|
||||
- **Manual increment required** — both loops require the loop variable to be manually advanced inside the body (`i++`); forgetting this creates an infinite loop, a warning the tutorial repeats for both variants. [S1]
|
||||
|
||||
## 📖 세부 내용 (Details)
|
||||
- While example: `int i = 0; while (i < 5) { Console.WriteLine(i); i++; }` → prints 0,1,2,3,4. [S1]
|
||||
- Do/while example: `int i = 0; do { Console.WriteLine(i); i++; } while (i < 5);` → identical output to the while version in this case, but the guarantee differs (body always runs at least once). [S1]
|
||||
|
||||
## ⚖️ 모순 및 업데이트 (Contradictions & updates)
|
||||
- **while/do-while이 C/C++와 완전히 동일한 문법·의미**: 조건 선검사(while) vs 후검사(do-while) 구조와 문법이 C/C++와 차이가 없다는 점이 확인됨. [S1]
|
||||
- **원문 구조상 while과 do-while이 한 챕터로 묶여 있음**: Topic_CPP에서는 While Loop와 Do While Loop가 별도 문서였지만, C# 사이드바는 이 둘을 cs_while_loop.php 하나의 페이지로 묶어 제공한다는 점이 확인됨 — 소스 사이트의 실제 챕터 구성을 그대로 따라 이 문서도 두 변형을 함께 다룸(1:1 매핑 원칙을 소스의 실제 챕터 단위에 맞춤). [S1]
|
||||
|
||||
## 🛠️ 적용 사례 (Applied in summary)
|
||||
0부터 4까지 출력하는 동일한 로직을 while과 do/while 두 가지 방식으로 각각 구현하는 예제가 원문에서 나란히 제시됨. [S1]
|
||||
|
||||
## 💻 코드 패턴 (Code patterns)
|
||||
while (pre-check) vs. do/while (post-check, runs at least once) (C#):
|
||||
```csharp
|
||||
int i = 0;
|
||||
while (i < 5)
|
||||
{
|
||||
Console.WriteLine(i);
|
||||
i++;
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
do
|
||||
{
|
||||
Console.WriteLine(j);
|
||||
j++;
|
||||
}
|
||||
while (j < 5);
|
||||
```
|
||||
|
||||
## ✅ 검증 상태 및 신뢰도
|
||||
- **상태:** draft
|
||||
- **검증 단계:** conceptual
|
||||
- **출처 신뢰도:** B (W3Schools — widely used educational reference, not a primary standards body)
|
||||
- **신뢰 점수:** 0.83
|
||||
- **중복 검사 결과:** 신규 생성 (New discovery)
|
||||
|
||||
## 🔗 지식 그래프 (Knowledge Graph)
|
||||
- **상위/루트:** [[C# Tutorial]]
|
||||
- **관련 개념:** [[CSharp Switch]], [[CSharp For Loop]], [[CPP While Loop]], [[CPP Do While Loop]]
|
||||
- **참조 맥락:** Loops 섹션 — For Loop 챕터로 이어짐.
|
||||
|
||||
## 📚 출처 (Sources)
|
||||
- [S1] W3Schools — C# While Loop — https://www.w3schools.com/cs/cs_while_loop.php
|
||||
|
||||
## 📝 변경 이력 (Change history)
|
||||
- 2026-07-04: Initial draft synthesized from the W3Schools "C# While Loop" page (Astra wiki-curation, P-Reinforce v3.1 format).
|
||||
Reference in New Issue
Block a user