So, I've just had the following conversation with a user in the comments section.
Me:
Year year = new Year{ State = States.Happy };
Them:
eventStream.ReceiveJoke += joke =>
Console.WriteLine($"Pretty nice joke: {joke}, Thanks!!!");
And, nerdy as I am, I wonder what he meant by the dollar sign but I think it's too embarrassing to ask him.
It's an interpolated string literal, introduced in C# 6.
It's broadly equivalent to:
eventStream.ReceiveJoke += joke =>
Console.WriteLine(string.Format("Pretty nice joke: {0}, Thanks!!!", joke));
The compiler looks for braces within any string literal introduced with $
, and applies string formatting to it. You can use (mostly) arbitrary expressions, rather than just variables, e.g.
Console.WriteLine($"{year.State} {2000 + 16}"); // Happy 2016
See more on this question at Stackoverflow