C# 11 - Raw strings

There is no escape!

Raw strings are delimited by 3 double-quotes and let you freely use up to 2 consecutive double-quotes without any escaping. They can also be combined with string interpolation.

var json = """
{
"name": "Lucy",
"age": 32
}
""";

ReSharper and Rider both support raw strings in various forms. For example, there's a To Raw String context action which allows you to convert all verbatim strings in your solution in one go.

With raw strings, you rarely have to worry about escaping again, and your code will look pretty even in the multiline form.!

See Also


Related Resources

C# 11 - Required Keyword
Introducing the required keyword for fields and properties.
Use collection initializers
Update and initialize items in old collection declarations
Rename refactoring
Would a variable by any other name read as clearly?