In C#, what does using a dollar sign do in Console.WriteLine

TJ Corey picture TJ Corey · Jul 23, 2016 · Viewed 14.7k times · Source

thank you for looking at my question, to verify what i mean

Console.WriteLine($"Hello {variable}");

I am curious to the effect that the $ has on the output from Console.WriteLine

Answer

topdog picture topdog · Jul 23, 2016
Console.WriteLine($"Hello {variable}");

Is I think equal to:

Console.WriteLine(string.Format("Hello {0}", variable));

It just moves the parameter into the index position as if you were formatting it.