String interpolation ( $ )
Embeds a variable/expression into text.
Syntax
$"... {expression} ..."Description
Putting a $ before the quotes turns the variables/expressions inside { } into their values. The most readable way to concatenate strings.
Example
Loading editor…
Expected output
Alex 36 years old Future: 37
When to use?
Printing variables by combining them with text.
Common mistakes
- ⚠️ Forgetting the $ sign: "{name}" is printed as-is, while $"{name}" inserts its value.