Better interpolated verbatim strings
We have already learned that string literals supports some variants to avoid escaping characters:
string s1 = "c:\\temp"; string s2 = @"c:\temp"; Assert.AreEqual(s1, s2);
They can also be used to improve formatting, thanks to interpolation:
var s3 = $"The path for {folder} is c:\\{folder}";
Since the introduction of interpolated strings, we have always been able to mix the two formatting styles:
var s4 = $@"The path for {folder} is c:\{folder}"; Assert.AreEqual(s3, s4);
But inverting the $
and @
characters was not possible before C# 8:
var s5 = @$"The path for {folder} is c:\{folder}"; Assert.AreEqual(s3, s5);
With this small improvement, you don't have to bother about the order of the prefixes.