I have been looking over some C# exercises in a book and I ran across an example that stumped me. Straight from the book, the output line shows as:

Console.WriteLine($"\n\tYour result is {result}.");

The code works and the double result shows as expected. However, not understanding why the $ is there at the front of the string, I decided to remove it, and now the code outputs the name of the array {result} instead of the contents. The book doesn’t explain why the $ is there, unfortunately.

I have been scouring the VB 2015 help and Google, regarding string formatting and Console.WriteLine overload methods. I am not seeing anything that explains why it is what it is. Any advice would be appreciated.

2 Answers
2

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *