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?
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.
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].
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.”
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.
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;  }  
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With