截取字符串

/// <summary>
/// 截取字符串
/// </summary>
/// <param name="text">需要截取的字符串</param>
/// <param name="maxLength">长度</param>
/// <param name="ishaspoint">是否需要省略号</param>
/// <returns>string</returns>
public static string substr(string text, int maxLength, bool ishaspoint)
{
  if (text.Length > maxLength)
  {
    if (ishaspoint)
      return text.Substring(0, maxLength) + "...";
    else
      return text.Substring(0, maxLength);
  }
  else

    return text;
}

posted @ 2018-07-06 15:48  GU天乐乐乐!  阅读(283)  评论(1编辑  收藏  举报