最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net中文字符串截取函数超出部份带省略号
时间:2022-06-25 04:00:26 编辑:袖梨 来源:一聚教程网
代码如下 | 复制代码 |
/// /// 将指定的字符串按指定的长度剪切 /// /// 需要剪切的字符串 /// 需要字符串的最大的长度 /// 超过长度的后缀 /// public static string StringTruncate(string oldStr, int maxLength, string endWith) { if (string.IsNullOrEmpty(oldStr)) return oldStr + endWith; if (maxLength < 1) throw new Exception("返回的字符串长度必须大于[0]"); if (oldStr.Length > maxLength) { string strTmp = oldStr.Substring(0, maxLength); if (string.IsNullOrEmpty(endWith)) return oldStr; else return oldStr + endWith; } return oldStr; } } |
相关文章
- 银与绯吉尔兰技能怎么样 吉尔兰战斗特性解析 07-14
- 异环异象管理局局长是谁 艾尔菲德角色详细介绍 07-14
- 欧意易ok官网下载版 欧意易app下载 07-14
- 迷你世界马车怎么做 马车制作方法介绍 07-14
- 碳碳岛许愿池有什么作用 许愿池建造方法介绍 07-14
- 最终幻想14水晶世界怎么招募雇员 招募雇员方法介绍 07-14