jsonecho

Escapar .NET (C#)

Prepara texto para insertarlo de forma segura en una cadena C#.

Cargando la herramienta...

Cómo usar Escapar .NET (C#)

  1. Pega el texto.
  2. Elige el estilo si es necesario.
  3. Copia el resultado.

Sobre Escapar .NET (C#)

Genera la forma escapada adecuada para cadenas C#, con opción de estilo verbatim (@"...").

What gets escaped

Backslash becomes \\, quotes become \" and \', line break \n, carriage return \r, tab \t, null \0, form feed \f, vertical tab \v. In verbatim mode only " becomes "".

Preguntas frecuentes

What is the difference between regular and verbatim strings?

In a regular string the backslash starts an escape sequence. In a verbatim string, written @"...", it does not, which makes file paths and regexes far more readable. Only the double quote has to be doubled.

Can a verbatim string contain line breaks?

Yes, it can span several lines, and the line breaks become part of the string.

What about interpolated strings?

In $"..." strings, curly braces also have a special meaning and must be doubled. This tool does not double them.

Since C# 11 there are raw string literals, should I use them?

If your project can use them, triple-quoted raw strings need no escaping at all, which is handy for JSON.

Más en Escape y texto

Todas las herramientas →