16 November

C# 11 – String interpolated new line

min. read

Reading Time: < 1 minute
C# 11
C# 11

Let’s list all the features that C# 11 brings to the table. Let’s discuss them all one by one, with their use cases, and see how they can come in handy. At the bottom of each article, you can find a link to all 14 new C# features!

String interpolated new line

In the previous releases of C#, we had problems when we tried to create a line break in the middle of a verbatim block.

var variable = "World";
var verbatim = $"Hello {variable.ToLower()}"; // Ok
var error = $"Hello {variable.  // <- error before C# 11

In new C# 11, you can now make line breaks in the middle of the variables. This will be useful for use cases when the line is too long and you are looking at the place to break it!

This is still one line when you print it!

Still in C# 10, how to do it then?

Before you had only the following options:

var break1 = "Hello " +
// This one might be inconvinient as it might print in 2 separate lines.
var break2 = [email protected]"Hello 

I like this change, it’s convenient!

Further reading at dotnet GitHub page.

Current article:
String interpolated new line


Tomasz Juszczak


Technical Lead

Tomasz Juszczak

About prog

Founded in 2016 in Warsaw, Poland. Prographers mission is to help the world put the sofware to work in new ways, through the delivery of custom tailored 3D and web applications to match the needs of the customers.

Let's talk