TextBox output line wrapping in C #

Source: Internet
Author: User

A lot of people in C #. NET platform programming encountered a problem, that is, the text should be wrapped in a TextBox, save to the file but there is no newline.

For example:

The text in the TextBox is:

12

34

56

and saved to the file is:

123456

No line break.

The reason is:

The newline in the textbox is executed on the window, and a newline is required \ r \ n When it is executed, so it is not possible to break the line, so we can use a textbox. Text.replace ("\ n", "\ r \ n") to implement line breaks,

But in the Linux system and other platforms is a newline or other, so there is no guarantee that the software on each platform is correctly wrapped, we also have a solution, that is to use the environment class;

The property newline in the environment class can get a newline string defined for this environment. Then we can easily solve the problem of correct line-wrapping of each platform.

TextBox output line wrapping in 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.