It creates an interpolated string.
From MSDN
Used to construct strings. An interpolated string expression looks like a template string that contains expressions. An interpolated string expression creates a string by replacing the contained expressions with the ToString represenations of the expressions’ results.
ex :
var name = "Sam";
var msg = $"hello, {name}";
Console.WriteLine(msg); // hello, Sam
You can use expressions within the interpolated string
var msg = $"hello, {name.ToLower()}";
Console.WriteLine(msg); // hello, sam
The nice thing about it is that you don't need to worry about the order of parameters as you do with String.Format
.
var s = String.Format("{0},{1},{2}...{88}",p0,p1,..,p88);
Now if you want to remove some parameters you have to go and update all the counts, which is not the case anymore.
Note that the good old string.format
is still relevant if you want to specify cultural info in your formatting.