Stats

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

Interpolated Verbatim Strings

Example

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");

Output:

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.