Nl2Br
Convert a NewLine to a Html break
Source
using System;
using System.Security.Cryptography;
using System.Text;
namespace MyExamples
{
static class StringExtensions
{
public static string Nl2Br(this string s)
{
return s.Replace("\r\n", "<br />").Replace("\n", "<br />");
}
}
}
Example
string s = "line1\r\n\line2";
string r = s.Nl2Br(); \\ "line1<br />line2"