Escape character escape character refers to a ' \ ' + a special character, consisting of a character with a special meaning. \ n: Represents a newline.
namespace _11.转义符
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("窗前明月光,\n疑是地上霜.\n举头望明月,\n低头思故乡.");
Console.ReadKey();
}
}
}
Note that you want to implement line breaks under the Windows operating system, we must write \ r \ n. The Mac operating system is supported by \ r.
\ ": Indicates the output double quotation mark.
Console.WriteLine("\"");
\ t: Tab (equivalent to pressing a TAB key)
Console.WriteLine("张三\t李四\t王五\t赵六\t田七");
\b: Backspace (equivalent to BACKSPACE on the keyboard)
Console.WriteLine("张三你妈妈\b喊你回家吃饭.");
If you want to enter a path, that is, "\" in the string does not play the role of escaping special characters, then what to do? For example: C:\Windows\System32 solution 1: In the "\" before adding a "\", is it escaped to a common "\".
Console.WriteLine("C:\\Windows\\System32");
Solution 2: Use the @ symbol
Console.WriteLine(@"C:\Windows\System32");
The function of the @ symbol: (1). Escapes the escaped symbol "\" in the string. (2). Output strings in the original format
Console.WriteLine(@"今天天气
好晴朗");
Note: Other escape symbols, using the same principle and the above example escape symbol is the same, the specific use of details, in the use of the need for specific review.
From for notes (Wiz)
The function of escape character and @ symbol in 11.c#