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
- Author: unknown
- Submitted on: 20-11-2007 01:11:33
- Language: C#
- Type: System.String
- Views: 4001
Double click on the code to select all.