1

I need to replace New Line with <br> in the string obtained from a text box.Currently i use this

string text= textbox.Text;
text.Replace(System.Environment.NewLine, "<br>");

But nothing is getting replaced when i test using MessageBox.show(text);

techno
  • 6,100
  • 16
  • 86
  • 192

1 Answers1

2

string.Replace returns a string. Do this:

string text= textbox.Text;
text = text.Replace(System.Environment.NewLine, "<br>"); //note the text = ...

You are almost there, except what you do in your code isn't returning the result of your string.Replace.

Ian
  • 30,182
  • 19
  • 69
  • 107