Difference between backslash/N and/R in C #

Source: Internet
Author: User

Recently, during my internship at the company, I encountered the character string Line Break Problem. Baidu found many character string line breaks and summarized the most basic points to avoid forgetting them.

\ N-> Line Break (New Line), which is used to display the string following the line break to the position starting with the next line"

 
Console. Write ("Features: [WeChat official website] accesses founder zhengzhong anytime and anywhere to obtain the latest futures information. \ N [micro-account opening] download the Founder's small-party account opening client to facilitate mobile account opening. \ N [menu] 1. Futures Information 2. Stock Information 3. Feedback");

Shown as follows:

The strings after \ n are displayed in a new line.

\ R-> carriage return (carriage return) is used to return \ r to the beginning of a line (the first line is returned), and the string before \ r is no longer displayed, as shown below.

 
Console. Write ("Features: [WeChat official website] accesses founder zhengzhong anytime and anywhere to obtain the latest futures information. \ N [micro-account opening] download the Founder's small-party account opening client to facilitate mobile account opening. \ R [menu] 1. Futures Information 2. Stock Information 3. Feedback");

 

Generally, \ r \ n is used to represent the carriage return line break, string STR = "the first line \ r \ n the second line ";

You can also use environment. newline (The namespace is system), environment is a class, and newline is a string attribute to obtain the carriage return linefeed string defined in the current environment.

String STR = "first line" + environment. newline + "second line ";

In Windows, the C # language environment. newline = "\ r \ n" returns true.

 

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.