先通过Reflector了解下String.Format方法

public static string Format(IFormatProvider provider, string format, params object[] args)
{
   
if ((format == null) || (args == null))
    {
       
throw new ArgumentNullException((format == null) ? "format" : "args");
    }
    StringBuilder builder =
new StringBuilder(format.Length + (args.Length * 8));
    builder.AppendFormat(provider, format, args);
   
return builder.ToString();
}

很显然,String.Format调用StringBuilder的类,但这也不能说明String.FormatStringBuilder快,也或者说StringBuilderString.Format更快,

只能说基本上是半斤八两(当然极限的时候还是有区别的,StringBuild的效率还是根据一些因素决定的,其中包括串连的数目、字符串的大小等等,

但最少以我们平时的编码的小数量来说,这样的区别可以忽略吧,对于目前的开发应用来说,没必要非得要分出个胜负,看应用场合吧)

PS:StringBuilder它是首先在创建字符串的时候同时创造一个缓冲区域,在对StringBuilder操作改变字符串数据值时,

StringBuilder会先检查缓冲区的大小是否足够容纳新的字符串数据。如果不够,则缓冲区的大小就会增加预先决定的数量。

由于大幅降低内存配置操作的发生机率,因此当然能有效提升效能。