Contributors: 10 Tuesday, August 9, 2016
Licensed under: CC-BY-SA
Not affiliated with Stack Overflow
Rip Tutorial:
Roadmap: roadmap

Interpolated Verbatim Strings

Download c# eBook


Verbatim strings can be combined with the new String interpolation features found in C#6.

Console.WriteLine($@"Testing \n 1 2 {5 - 2}
New line");


Testing \n 1 2 3
New line

Live Demo on .NET Fiddle

As expected from a verbatim string, the backslashes are ignored as escape characters. And as expected from an interpolated string, any expression inside curly braces is evaluated before being inserted into the string at that position.