jrliv
5/13/2017 - 12:32 AM

Example of using escape sequences, string literals and verbatim string while printing.

Example of using escape sequences, string literals and verbatim string while printing.

// Most frequently used escape characters.
Console.WriteLine("\'");	// single quote
Console.WriteLine("\"");	// double quote
Console.WriteLine("\\");	// backslash
Console.WriteLine("Before new line \nAfter new Line");	// new line
Console.WriteLine("Tab \t tab");	// tab
Console.WriteLine("\u004A");	// char specified by Unicode
Console.WriteLine("Quotes in strings are \"really\" hard to deal with.");
//  Quotes in strings are "really" hard to deal with.

// Print a string verbatim. Add @ before the string.  
Console.WriteLine(@"This \\ string \t ignores \' all \n the escape characters.");
//  This \\ string \t ignores \' all \n the escape characters.