Most efficent way of joining strings

前端 未结 11 1870
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 05:51

I need to concatenate a lot of strings alltogether and put a comma between any of them. I have a list of strings

\"123123123213\"
\"1232113213213\"
\"1232131         


        
11条回答
  •  失恋的感觉
    2021-01-18 06:49

    If one wants to be cool and run on Heavy Fuel use Aggregate

    List stringList = new List { "1234567890", "34343434", "4343434" };
    
    Console.WriteLine( stringList.Aggregate( ( current, next ) => string.Format( "{0}, {1}", current, next ) ) );
    
    // Outputs:   1234567890, 34343434, 4343434
    

提交回复
热议问题