Join us for a free 2-day community event – JetBrains .NET Days Online 2024

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
C# 11 - Required Keyword
Introducing the required keyword for fields and properties.
File-scoped namespaces and types
File-scoped namespaces and types
Organize code better and reduce bugs by using file-scoped namespaces and objects.
C# Top-level statements
C# Top-level statements
Use top-level statements in C# to reduce boilerplate code.