quot;Hello, {name}!". It is easier to read than composite formatting with {0} placeholders. [S1][S2]">

← All notes

C# string interpolation and format strings

Short answer

Prefix a string with $ and put expressions in braces: $"Hello, {name}!". It is easier to read than composite formatting with {0} placeholders. [S1][S2]

Console.WriteLine($"{item,-10}{price,8:C}{rate:P0}");

Key points

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Microsoft Learn (.NET docs), Learn string interpolation - C#, CC BY 4.0 (dotnet/docs); Microsoft Learn (.NET docs), $ - string interpolation - format string output - C# reference, CC BY 4.0 (dotnet/docs).

Cite this

Permanent ID: iil:note:m6k9px5c

iinventedlight. 2026. "C# string interpolation and format strings." iinventedlight Library, iil:note:m6k9px5c, version of 2026-11-04. https://iinventedlight.com/library/notes/csharp-string-interpolation/. License: CC-BY-4.0.

@misc{iil_note_m6k9px5c,
  author = {{iinventedlight}},
  title = {{C\# string interpolation and format strings}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/csharp-string-interpolation/},
  note = {Permanent ID iil:note:m6k9px5c. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/csharp-string-interpolation.md.