1 min read

C# Strings with Interpolation, Multiline

Just a bit of useful knowledge (depending on how often it affects you, I was writing a longer query into my code).

I've loved the interpolation (@) operator since it was introduced into C# a few versions ago. Talk about convenience, aside from some performance concerns.

I was just working on pasting in a multi-line SQL query, and low and wanted to that with multi-line strings. Low and behold, combining two operators works:

string xyz = $@"Here is a string with {someVariable} interpolated
	and spread over two lines.";

Fun fact, and hopefully a bit useful.