String Interpolation

The .NET languages allow you to replace portions of a string with values. To do so, you use String.Format or StringBuilder.AppendFormat. These methods allow you to use placeholders as numbers inside curly braces. These numbers are replaced in series by the values that follow. This is cumbersome to write and can lead to confusion.

In 2015, the code editor allows you to put the variable right in the middle of the string. You do so using the format that starts the string with a dollar sign ($) as an escape character. You can then add curly braces within the string to reference variables, as in {value}. The editor gives you IntelliSense for your values, too. The call to String.Format then happens for you behind the scenes. The ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.