美文网首页
C#字符串截取函数的代码

C#字符串截取函数的代码

作者: xintiantian | 来源:发表于2019-01-11 11:52 被阅读0次

下面内容段是关于C#字符串截取函数的内容,应该能对小伙伴们有些用途。

public static string Truncate(this string myString, int limit, string symbol)

{

    if (myString == null)

        return null;

    if (limit < 0)

        throw new ArgumentOutOfRangeException("limit", limit, "must be 0 or greater");

    if (symbol == null)

        throw new ArgumentNullException("symbol must not be null");

    if (myString.Length < limit)

        return myString;

    return myString.Substring(0, limit) + symbol;

}

相关文章

  • C#字符串截取函数的代码

    下面内容段是关于C#字符串截取函数的内容,应该能对小伙伴们有些用途。 public static string T...

  • 2018-07-30

    100个常用的javascript函数 1、原生JavaScript实现字符串长度截取 复制代码代码如下: fun...

  • 80%的人不知道的【MIDB】函数用法,你会吗?

    在前面已经学习了截取字符串函数中的LEFTB函数和RIGHTB函数,今天本文继续讲解截取字符串函数——MIDB函数...

  • MySQL字符串截取的4个函数

    mysql字符串截取的4个函数 tags:mysql 字符串截取 1、从左开始截取字符串 left(str, le...

  • mysql截取字符串

    Author:杜七 Date:2017.03.15 字符串截取 MySQL 字符串截取函数:left(), rig...

  • PHP字符串处理函数

    字符串长度函数 字符串替换函数 截取字符串函数 分割、连接、反转函数 空白处理函数 字符转义函数 字符串比较函数

  • 【MID】文本截取函数如何使用?

    在前面已经学习了截取字符串函数中的LEFT函数和RIGHT函数,今天本文继续讲解截取字符串函数中的最后一个函数——...

  • MySQL函数:字符串如何截取

    练习截取字符串函数(五个) mysql索引从1开始 一、mysql截取字符串函数 1、left(str,lengt...

  • instr函数

    Oracle中的字符串截取函数 instr

  • PHP基础2

    函数补充 字符串函数 substr截取字符串$string="abcdefg;echo substr($strin...

网友评论

      本文标题:C#字符串截取函数的代码

      本文链接:https://www.haomeiwen.com/subject/gwtxdqtx.html