Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

For the case you described, where performance is not a bottleneck, I believe it's all about personal taste.

In thisthis SO discussion, it seems a majority prefers to use the 2nd approach.

I however, am a strong believer of staying consistent. If you use the StringBuilder class in other classes of your project, stick to using it.

However, When initializing a StringBuilder, you are going down in performance, so I wouldn't advise to use it for single concatenations. A guideline according to this article is to use a StringBuilder when four or more string concatenations take place (which is the case in your example.)

For the case you described, where performance is not a bottleneck, I believe it's all about personal taste.

In this SO discussion, it seems a majority prefers to use the 2nd approach.

I however, am a strong believer of staying consistent. If you use the StringBuilder class in other classes of your project, stick to using it.

However, When initializing a StringBuilder, you are going down in performance, so I wouldn't advise to use it for single concatenations. A guideline according to this article is to use a StringBuilder when four or more string concatenations take place (which is the case in your example.)

For the case you described, where performance is not a bottleneck, I believe it's all about personal taste.

In this SO discussion, it seems a majority prefers to use the 2nd approach.

I however, am a strong believer of staying consistent. If you use the StringBuilder class in other classes of your project, stick to using it.

However, When initializing a StringBuilder, you are going down in performance, so I wouldn't advise to use it for single concatenations. A guideline according to this article is to use a StringBuilder when four or more string concatenations take place (which is the case in your example.)

Source Link
DJanssens
  • 1.5k
  • 1
  • 15
  • 27

For the case you described, where performance is not a bottleneck, I believe it's all about personal taste.

In this SO discussion, it seems a majority prefers to use the 2nd approach.

I however, am a strong believer of staying consistent. If you use the StringBuilder class in other classes of your project, stick to using it.

However, When initializing a StringBuilder, you are going down in performance, so I wouldn't advise to use it for single concatenations. A guideline according to this article is to use a StringBuilder when four or more string concatenations take place (which is the case in your example.)