I have read several articles (for example, www.adopenstatic.com/experiments/stringconcatenation.asp
) where the inefficiency of string concatentation is discussed.
I have lots of code that builds a web page with a long sequence of string concatenations, such as the following:
strHTML = ""
strHTML = strHTML & strHTMLcode1
strHTML = strHTML & strHTMLcode2
strHTML = strHTML & strHTMLcode3
strHTML = strHTML & strHTMLcode4
strHTML = strHTML & strHTMLcode5
strHTML = strHTML & strHTMLcode6
and so on, where "strHTMLcodeX" is some actual HTML. These concatenations often go on for between 50 or 100 lines (maybe more).
The code is not necessarily needed right away, so simple replacement with Response.Write calls would not often be the best approach.
My first inclincation would simply to replace the above with the following:
strHTML = strHTMLcode1 & strHTMLcode2 & strHTMLcode3 & strHTMLcode4 & strHTMLcode5 & strHTMLcode6
However, this seems kind of ugly, especially with 100 variables and literals.
Can anyone recommend a nicer approach?