$ (C# Reference)

Identifies a string literal as an interpolated string. An interpolated string is a template-like string that contains literal text along with interpolated expressions. When the interpolated string is resolved, for example in an assignment statement or a method call, its interpolated expressions are replaced by their string representations in the result string. Interpolated strings are replacements for the composite format strings supported by the .NET Framework.

The following example uses the $ character to define an interpolated string.

using System;

public class Example
   public static void Main()
      string name = "John";
      string greeting = $"Hello, {name}!";
// The example displays the following output:
//       Hello, John!

For more information on interpolated strings, see the Interpolated Strings topic.

See Also

C# Reference
C# Programming Guide
C# Special Characters