用stringbuilder的append方法效率较高 

解决方案 »

  1.   

    那样一样需要用到循环啊,那个文件有3万多行,如果是append,那就需要用3万多次append,速度行吗?
      

  2.   

    不append,你给加起来?觉得效率慢,自己写一个?搞笑!
      

  3.   

    System.String.Concat(string[] abc);[C#] 
    using System;public class ConcatTest {
        public static void Main() {        // make an array of strings. Note that we have included spaces
            string [] s = { "hello ", "and ", "welcome ", "to ", "this ", "demo! " };        // put all the strings together
            Console.WriteLine(string.Concat(s));        // sort the strings, and put them together
            Array.Sort(s);
            Console.WriteLine(string.Concat(s));
        }
    }
      

  4.   

    Concat() 
    在内部调用了 stringbuilder.append
    stringbuilder效率最高,3万行一行20个字算才60万个字 ,一个汉字2byte , 8bit
    也就4M内存足够放的下了,在加上其他开销和IO,如果不是需要经常转换不用去管性能的