Sunday, October 18, 2009

TIPS: Fastest way to concatenate multiple strings in VB.NET

I wonder why my codes a lot more slower than my collegue's. Finally I detect something. It was the way how I concatenate the multiple strings. I always tend to use "&=" operator to concatenate multiple strings. While this way was a bit more faster than using "+=" operator, It's unfortunately 1000 times slower than using StringBuilder class!

Somebody has done comparison on this and it's really true!

Always use the StringBuilder when concatenate multiple strings especially when the text length is not small. Remember this!