当前位置: 代码迷 >> ASP.NET >> 一下这段功能的每一句代码什么意思。新手
  详细解决方案

一下这段功能的每一句代码什么意思。新手

热度:4855   发布时间:2013-02-25 00:00:00.0
求高手指教一下这段功能的每一句代码什么意思。新手
求高手指教一下这段功能的每一句代码什么意思。最好在每一句后面加上注释


C# code
#region 用于处理多行文本的公共方法    /// <summary>    /// 返回多行输入的字符串并删除超过限定字数的字符同时进行Html编码    /// </summary>    /// <param name="instr">要过滤的字符串</param>    /// <param name="WordCount">保留的字数</param>    /// <param name="NewLine">设置一个值,该值表示是否显示换行符。</param>    /// <returns></returns>    private static string MultiLineStrConv(string instr, int WordCount, bool NewLine)    {        instr = instr.Trim();        objregex = new Regex(" +");        instr = objregex.Replace(instr, " ");        instr = instr.Replace(Environment.NewLine + " ", Environment.NewLine);        instr = instr.Replace(" " + Environment.NewLine, Environment.NewLine);        instr = instr.Replace(Environment.NewLine + Environment.NewLine, Environment.NewLine);        instr = HttpContext.Current.Server.HtmlEncode(instr);        instr = instr.Replace("'", "''");        if (NewLine)        {            instr = instr.Replace(Environment.NewLine, "<br />" + Environment.NewLine);        }        if (WordCount > 0 && instr.Length > WordCount)        {            instr = instr.Substring(0, WordCount);        }        return instr;    }    #endregion


------解决方案--------------------------------------------------------
就是对指定长度字符串进行html编码啊
  相关解决方案