Raw String Literals
Write multiline and quote-heavy text cleanly.
Raw String Literals
A raw string literal is wrapped in at least three double quotes. Inside, characters are taken literally, with no escape processing.
using System;
class Program {
static void Main() {
string s = """Hello "World"!""";
Console.WriteLine(s);
}
}No Escape Sequences
Backslashes are plain backslashes inside a raw string, which is perfect for file paths and regex patterns.
using System;
class Program {
static void Main() {
string path = """C:\Users\Ada\file.txt""";
Console.WriteLine(path);
}
}