What are the escape sequences supported by C#?



The following is an example showing how to display some of the escape characters in C# −

Example

using System;
using System.Collections.Generic;

class Demo {
   static void Main() {

      Console.WriteLine("Warning!" + '\u0007');

      Console.WriteLine("Test \t Demo Text");

      Console.WriteLine("This is it!
This is on the next line!");    } }

For the complete list of escape sequences in C# −

Escape characterDescriptionPattern
\aMatches a bell character, \u0007.\a
\bIn a character class, matches a backspace, \u0008.[\b]{3,}
\tMatches a tab, \u0009.(\w+)\t
\rMatches a carriage return, \u000D. (\r is not equivalent to the newline character,
.)
\r
(\w+)
\vMatches a vertical tab, \u000B.[\v]{2,}
\fMatches a form feed, \u000C.[\f]{2,}

Matches a new line, \u000A.\r
(\w+)
\eMatches an escape, \u001B.\e
karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know


Advertisements