Most efficient way to concatenate strings?

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

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

17条回答
  •  离开以前
    2020-11-22 03:56

    If you're operating in a loop, StringBuilder is probably the way to go; it saves you the overhead of creating new strings regularly. In code that'll only run once, though, String.Concat is probably fine.

    However, Rico Mariani (.NET optimization guru) made up a quiz in which he stated at the end that, in most cases, he recommends String.Format.

提交回复
热议问题