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