By 22/07/2015 13 Comments

C# Regular String Escape Sequences

  • They are used for new lines, set double quotation, give white spaces, tabs etc in string literals.
ESCAPE SEQUENCE DESCRIPTION
\” Print string literals in double quotes.
\’ Print string literals in single quotes.
\a When you debug program, an alert or bell will be ringed.
\n Print string literals at new line.
\t Create a horizontal tab space between your string literals.
\v Create an vertical tab space between your string literals, this does not affect on screen output, this is device specific used for printers.
\b Create a backspace between your string literals.
\\ Backslash.
\0 Null.
\f Form feed, this does not affect on screen output, and this is device specific used for printers.
\r Carriage return.

Example:

// start class definition / declaration  
class Program
{   
   // static main method void type declaration   
   static void Main(string[] args)
   {
                 // following string literal is using double quotes: \" \"
         Console.WriteLine("C# is a strongly typed and \"Object oriented programming language\"");

		 // following string literal is using single quotes: \' \'
         Console.WriteLine("Microsoft visual studio is a greatest \'IDE\'");

		 // following string literal is using alert (bell): \a
         Console.WriteLine("\a this line is responsible for alert an bell");

		  // following string literal is using new line: \n
         Console.WriteLine("this is line 1 \n this is a new line");

		  // following string literal is using horizontal tab: \t
         Console.WriteLine("this is a line \t this line is after horizontal tab space");

		  // following string literal is using vertical tab: \v
         Console.WriteLine("\v this does not affect on screen output, this is device specific used for printers");

		  // following string literal is using backspace: \b
         Console.WriteLine("\t\b this line is after tab, but later it is backspaced");

		  // following string literal is using backslash: \\
         Console.WriteLine("this line has a \\ backslash");

		  // following string literal is using null: \0
         Console.WriteLine("\0 this line starts after little space");

		  // following string literal is using form feed: \f
         Console.WriteLine("\f this does not affect on screen output, this is device specific used for printers");

		  // following string literal is using carriage return: \r
         Console.WriteLine("\r this line uses carriage return");

         Console.ReadKey();
    }   // End of main method definition
}       // End of class definition






Next Tutorial →


← Previous Tutorial


Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .