#Interpolated strings#Interpolated strings were added into C# 6.0 and Visual Basic 14 (bothBoth were introduced through new Roslyn compiler in Visual Studio 2015).
C# 6.0:
return "\{someVariable} and also \{someOtherVariable}"OR
return $"{someVariable} and also {someOtherVariable}"source: what's new in C#6.0
VB 14:
return $"{someVariable} and also {someOtherVariable}"source: what's new in VB 14
Noteworthy features (in Visual Studio 2015 IDE):
- syntax coloring is supported - variables contained in strings are highlighted
- refactoring is supported - when renaming, variables contained in strings get renamed, too
- actually not only variable names, but expressions are supported - e.g. not only
{index}works, but also{(index + 1).ToString().Trim()}
Enjoy! (& click "Send a Smile" in the VS)