The function of escape character and @ symbol in 11.c#

Source: Internet
Author: User

Escape character escape character refers to a ' \ ' + a special character, consisting of a character with a special meaning. \ n: Represents a newline.
  
 
  1. namespace _11.转义符
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. Console.WriteLine("窗前明月光,\n疑是地上霜.\n举头望明月,\n低头思故乡.");
  8. Console.ReadKey();
  9. }
  10. }
  11. }
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.
 
   
  
  1. Console.WriteLine("\"");

\ t: Tab (equivalent to pressing a TAB key) 
 
   
  
  1. Console.WriteLine("张三\t李四\t王五\t赵六\t田七");

\b: Backspace (equivalent to BACKSPACE on the keyboard)
 
   
  
  1. 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 "\".
 
   
  
  1. Console.WriteLine("C:\\Windows\\System32");
Solution 2: Use the @ symbol
 
   
  
  1. 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
 
   
  
  1. Console.WriteLine(@"今天天气
  2. 好晴朗");

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#

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.