Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding line break

Tags:

c#

line-breaks

I have a problem with adding line break in a string. I have tried using "\r\n", and Environment.NewLine also does not work.

FirmNames = "";  foreach (var item in FirmNameList) {     if (FirmNames != "")     {        FirmNames += ", " + LineBreak;  -- I want a line break here after the comma ","     }      FirmNames += item; } 

Can anyone help?

like image 728
Jenny Avatar asked Jan 21 '11 03:01

Jenny


People also ask

What does it mean to add a line break?

Line-break definition (typography) A point in writing where text that would normally continue on the same line starts at the beginning of a new line. noun. (computing) A character indicating that subsequent characters should appear on a separate line of text; newline, line feed. noun.

How do I insert a line break in Word?

At the end of the sentence, press the Tab key and then then insert the manual line break in Word by using the key combination [Enter] + [Shift].

What is a line break example?

First, a line break cuts the phrase, “I mete and dole unequal laws unto a savage race,” into two at the end of the first line. Similarly, a break occurs in other lines like “I will drink life to lees,” “All times I have enjoyed greatly, have suffer'd greatly,” and “I am become a name.”

How do you insert a line break in a paragraph?

Line Breaks - Hold Shift and Press Enter When a line break is inserted the cursor moves down a single line, which is different from the paragraph which ends the paragraph and starts a new one.


1 Answers

The correct answer is to use Environment.NewLine, as you've noted. It is environment specific and provides clarity over "\r\n" (but in reality makes no difference).

foreach (var item in FirmNameList)  {     if (FirmNames != "")     {         FirmNames += ", " + Environment.NewLine;     }     FirmNames += item;  }  
like image 99
Kirk Broadhurst Avatar answered Sep 19 '22 17:09

Kirk Broadhurst