Most efficient way to concatenate strings?

后端 未结 17 1595
野趣味
野趣味 2020-11-22 03:04

What\'s the most efficient way to concatenate strings?

17条回答
  •  佛祖请我去吃肉
    2020-11-22 03:57

    Another solution:

    inside the loop, use List instead of string.

    List lst= new List();
    
    for(int i=0; i<100000; i++){
        ...........
        lst.Add(...);
    }
    return String.Join("", lst.ToArray());;
    

    it is very very fast.

提交回复
热议问题