string.Join和string.Concat的区别

源自 Difference between String.Join() vs String.Concat()

With .NET 4.0, String.Join() uses StringBuilder class internally so it is more efficient.
Whereas String.Concat() uses basic concatenation of String using "+" which is of course not an efficient approach as String is immutable.

I compared String.Join() in .NET 2.0 framework where its implementation was different(it wasn't using StringBuilder in .NET 2.0). But with .NET 4.0, String.Join() is using StringBuilder() internally so its like easy wrapper on top of StringBuilder() for string concatenation.

Microsoft even recommends using StringBuilder class for any string concatenation.

I would prefer String.Join() over String.Concat()

你可能感兴趣的:(String)