554 Contributors: 19 Thursday, December 8, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap
Download eBook

String Interpolation

Download c# eBook


  • $"content {expression} content"
  • $"content {expression:format} content"
  • $"content {expression} {{content in braces}} content}"
  • $"content {expression:format} {{content in braces}} content}"


String interpolation is a shorthand for the string.Format() method that makes it easier to build strings with variable and expression values inside of them.

var name = "World";
var oldWay = string.Format("Hello, {0}!", name);  // returns "Hello, World"
var newWay = $"Hello, {name}!";                   // returns "Hello, World"

Related Examples