0Pricing
C# Academy · Lesson

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);
    }
}

All lessons in this course

  1. String Interpolation Basics
  2. Composite Formatting with string.Format
  3. Numeric and Date Format Specifiers
  4. Raw String Literals
← Back to C# Academy