Nl2Br

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"

Description

Convert a NewLine to a Html break

Details

Double click on the code to select all.

 

;