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