截取字符串

/// <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 BIGBOY_CHUANQI 阅读(...) 评论(...) 编辑 收藏