5

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

Rahul
  • 76,197
  • 13
  • 71
  • 125
TJ Corey
  • 51
  • 1
  • 1
  • 2

2 Answers2

14
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.

topdog
  • 377
  • 1
  • 7
6

It is a new feature to use in addition to string.Format

It's called Interpolated Strings

Thaina Yu
  • 1,372
  • 2
  • 16
  • 27