--- 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 `` header, no `std::string` namespace qualifier β€” collapsing what took C an entire "no native strings" caveat and C++ a dedicated Strings section (`` 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++λŠ” `` 헀더와 `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).