换行

1.在文本换行,可以使用System.Environment.NewLine

2.System.Environment.NewLine 大多数情况下,被转化为 \r\n.

3.\r\n在存入数据库的时候,就只有\n了。

4.

        public static string TextToHtml(string content)
        {
            if (string.IsNullOrEmpty(content))

           {

              return string.Empty;

          }
            text = HttpUtility.HtmlEncode(content);
            return content.Replace("\r\n", "<br/>").Replace("\n", "<br/>").Replace(" ", "&nbsp;").Replace("\r", "<br/>");
        }

5.

        public static string ClearHtml(string content)
        {
            return content.Replace("<BR>", "").Replace("\r\n", "").Replace("<br>", "").Replace("<P>", "").Replace("</P>", "").Replace("&nbsp;", "").Trim().Replace(" ", "");
        }

 

 

你可能感兴趣的:(换行)