$ (Visual Basic 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. An interpolated expression is an expression that produces a result to be formatted in the resultant string. 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.

Public Module Example
   Public Sub Main()
      Dim name = "John"
      Dim greeting = $"Hello, {name}!"
      Console.WriteLine(greeting)
   End Sub
End Module
' The example displays the following output:
'       Hello, John!
                   

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

See also