-3

How can I replace the line break of a textbox (multiline-box) by the html's <br>?

This is my code:

string output = tb_Notizen.Text.Replace("\\r\\n", "<br>");

Whats wrong here?

I already tried it with \r\n but it didn't worked too...

gpmurthy
  • 2,397
  • 19
  • 21
bbholzbb
  • 1,832
  • 3
  • 19
  • 28
  • 4
    I don't know, what *is* wrong? What "didn't worked"? Please post more example input, expected output, and actual output. – tnw Nov 12 '13 at 19:39
  • Maybe try Google first: [Replace Line Breaks in a String C#](http://stackoverflow.com/questions/238002/replace-line-breaks-in-a-string-c-sharp) – tnw Nov 12 '13 at 19:40

1 Answers1

1

Better try with Environment.NewLine because \r and \n are platform dependant.

\n is Unix, \r is Mac, \r\n is Windows

Environment.NewLine would return any of the above based on the operating system.

string output = tb_Notizen.Text.Replace(Environment.NewLine, "<br>");
Kurubaran
  • 8,696
  • 5
  • 43
  • 65