-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...

2
  • 4
    I don't know, what is wrong? What "didn't worked"? Please post more example input, expected output, and actual output. Commented Nov 12, 2013 at 19:39
  • Maybe try Google first: Replace Line Breaks in a String C# Commented Nov 12, 2013 at 19:40

1 Answer 1

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>");
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.