String - Nl2Br

A string extension method that newline 2 line break.

Try it

public static void Main()
{
	string str = "To break lines\r\n in a text,\n use the br element.";

	// C# Extension Method: String - Nl2Br
    string content = str.Nl2Br();
	
	Console.WriteLine(content);
}

View Source
public static partial class Extensions
{
    /// <summary>
    ///     A string extension method that newline 2 line break.
    /// </summary>
    /// <param name="this">The @this to act on.</param>
    /// <returns>A string.</returns>
    public static string Nl2Br(this string @this)
    {
        return @this.Replace("\r\n", "<br />").Replace("\n", "<br />");
    }
}