Files
2nd/10_Wiki/Dev/Topic_CSharp/CSharp_Strings_Interpol.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

4.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
csharp-strings-interpol C# String Interpolation Programming_Language draft conceptual
$ string C#
interpolated strings
C# 문자열 보간
B 0.84 2026-07-04 2026-07-04
csharp
programming-language
w3schools
strings
interpolation
https://www.w3schools.com/cs/cs_strings_interpol.php

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#):

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)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-07-04: Initial draft synthesized from the W3Schools "C# String Interpolation" page (Astra wiki-curation, P-Reinforce v3.1 format).