asp.net截取指定长度的字符串内容

 1  /// <summary>
 2     /// 用于截取指定长度的字符串内容
 3     /// </summary>
 4     /// <param name="sString">用于截取的字符串</param>
 5     /// <param name="nLength">截取字符串的长度</param>
 6     /// <returns>返回截取后的字符串</returns>
 7     public string SubStr(string sString,int nLength)
 8     {
 9         if (sString.Length <= nLength)
10         {
11             return sString;
12         }
13         string sNewStr = sString.Substring(0, nLength);
14         sNewStr = sNewStr + "...";
15         return sNewStr;
16     }

 

posted @ 2016-11-26 19:20  清风白水  阅读(1913)  评论(0编辑  收藏  举报