tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Interpolated verbatim string in C# 8

18 Jan 2019 1 mins C#

As I was talking yesterday about new big features in C# 8, I learned about a small feature coming to this version as well that simplifies usage of interpolated verbatim strings.

Today, if you want to use interpolated verbatim string, you have to place the $ and @ in proper order. So, this $@"test {DateTime.UnixEpoch}" works, while @$"test {DateTime.UnixEpoch}" doesn’t (Wondering about DateTime.UnixEpoch? Look here.). I was always kind of OK with it. In my mind I explained to myself that the @ defines how the content inside double quotes behaves, it’s a modifier of the double quotes and hence needs to in front of the opening one. While the $ is like new FormattableString (I know it’s an abstract class, but there’s a FormattableStringFactory if you’d really like to create it manually), which obviously needs to be first.

But having to type it in correct order was apparently pain in the ass and so in C# 8 the order will not matter. You can try that in i.e. preview of VS 2019 or here.

interpolated verbatim string in VS 2019 Preview


Visual Studio 2019 starting with Preview 2 contains auto-fixer to replace @$" with $@".

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at