Tuesday, June 3, 2008

Replace newline to blank in .NET

For example in C#

protected void Page_Load(object sender, EventArgs e)
{
string str = "Hello \r\n world";
Response.Write(str);
Response.Write("<br/>\n");
str = str.Replace(Environment.NewLine, string.Empty);
Response.Write(str);
}

Then preview in browser and view html source.

* Environtment.NewLine is equal to \r\n

No comments:

Post a Comment