源自Difference between String.Join() vs String.Concat()

With .NET 4.0, String.Join() uses StringBuilder class internally so it is more efficient.
Whereas String.Concat() uses basic concatenation of String using "+" which is of course not an efficient approach as String is immutable.

I compared String.Join() in .NET 2.0 framework where its implementation was different(it wasn't using StringBuilder in .NET 2.0). But with .NET 4.0, String.Join() is using StringBuilder() internally so its like easy wrapper on top of StringBuilder() for string concatenation.

Microsoft even recommends using StringBuilder class for any string concatenation.

I would prefer String.Join() over String.Concat()

string.Join和string.Concat的区别的更多相关文章

  1. String.Join重载String.Join 方法 (String, String[], Int32, Int32)

    https://msdn.microsoft.com/zh-cn/library/tk0xe5h0 String.Join 方法 (String, String[], Int32, Int32) 官方 ...

  2. 教你50招提升ASP.NET性能(二十三):StringBuilder不适用于所有字符串连接的场景;String.Join可能是

    (41)StringBuilder is NOT the answer for all string concatenation scenarios; String.Join could be 招数4 ...

  3. String.Join Method

    Overloads Join(String, String[], Int32, Int32) Concatenates the specified elements of a string array ...

  4. BCL中String.Join的实现

    在开发中,有时候会遇到需要把一个List对象中的某个字段用一个分隔符拼成一个字符串的情况.比如在SQL语句的in条件中,我们通常需要把List<int>这样的对象转换为“1,2,3”这样的 ...

  5. string.Join和Reverse的简单使用示例

    String.Join 方法 (String, String[]) 串联字符串数组的所有元素,其中在每个元素之间使用指定的分隔符. 例如,如果 separator 为“,”且 value 的元素为“a ...

  6. String.Join的实现

    String.Join的实现 在开发中,有时候会遇到需要把一个List对象中的某个字段用一个分隔符拼成一个字符串的情况.比如在SQL语句的in条件中,我们通常需要把List<int>这样的 ...

  7. Java8中String.join方法

    List names=new ArrayList<String>(); names.add("1"); names.add("2"); names. ...

  8. C# string.join

    String.Join 方法 平常工作中经常用到string.join()方法,在vs 2017用的运行时(System.Runtime, Version=4.2.0.0)中,共有九个(重载)方法. ...

  9. String.Join函数

    string[] str1 = { "abc", "bcd", "cde", "efg" }; string str2 ...

随机推荐

  1. 构造函数继承关键apply call

    主要我是要解决一下几个问题: 1.        apply和call的区别在哪里 2.        apply的其他巧妙用法(一般在什么情况下可以使用apply) 我首先从网上查到关于apply和 ...

  2. Cassandra1.2文档学习(19)—— CQL索引

    参考文档:http://www.datastax.com/documentation/cql/3.0/webhelp/index.html#cql/ddl/ddl_primary_index_c.ht ...

  3. 手工添加Linux防火墙端口

    在linux实际操作中经常需要对防火墙进行修改,比如经常要修改或添加相关端口,下面以添加运行Tomcat所需8080端口为例: (以下命令操作均为root用户) 1.编辑iptables文件 # vi ...

  4. 《C和指针》 读书笔记 -- 第9章 字符串、字符和字节

    1.字符串以NUL结尾,但字符串长度不包括NUl字节. 2.复制字符串 char *strcpy(char *dst,char const *src); 3.连接字符串 char *strcat(ch ...

  5. PAT乙级真题1006. 换个格式输出整数 (15)(解题)

    原题: 让我们用字母B来表示“百”.字母S表示“十”,用“12...n”来表示个位数字n(<10),换个格式来输出任一个不超过3位的正整数.例如234应该被输出为BBSSS1234,因为它有2个 ...

  6. Java中的异常处理(二)

    1.finally package second; public class C { public static void main(String[] args){ String name = nul ...

  7. 让用户打开你app的位置功能

    +运动 http://www.ccidnet.com/2015/0819/10014152.shtml 让你的app不再是一个购物网站, 而是一种生活方式, 逛街,在实体店逛街积累里程,兑换积分  送 ...

  8. linux grep、find 命令详解

    grep1.作用grep命令可以指定文件中搜索特定的内容,并将含有这些内容的行标准输出.grep全称是Global Regular Expression Print,表示全局正则表达式版本,它的使用权 ...

  9. linux编程之指针

    这个是数组指针.指针数组.二维数组之间相互转换的代码 #include<stdio.h> void main() { ][]={,,,,,,,}; int *b=NULL; int **c ...

  10. c#无标题窗体点击任务栏图标正常最小化或还原

    FormBorderStyle等于System.Windows.Forms.FormBorderStyle.None的窗体,点击任务栏图标的时候,是不能象标准窗体那样最小化或还原的. protecte ...