Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Variables.md
T
Antigravity Agent 1cfd3bbb56 docs(10_Wiki): 위키 구조 정리 — 언어 튜토리얼 카테고리 폴더 제거 + 신규 자산 동기화
Topic_CSS/Topic_HTML/Topic_JavaScript/Topic_Prompt/Topic_Comfyui 등 기존 카테고리 폴더를 정리하고,
Topic_Graphic/Dev 등 신규 산출물과 Topics 내부 세션/메모리 기록을 동기화.
2026-07-05 00:10:59 +09:00

76 lines
4.0 KiB
Markdown

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