Most efficient way to concatenate strings?

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

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

17条回答
  •  我在风中等你
    2020-11-22 03:39

    For just two strings, you definitely do not want to use StringBuilder. There is some threshold above which the StringBuilder overhead is less than the overhead of allocating multiple strings.

    So, for more that 2-3 strings, use DannySmurf's code. Otherwise, just use the + operator.

提交回复
热议问题