View Single Post
  #2 (permalink)  
Old November 10th, 2004, 06:36 PM
jaucourt jaucourt is offline
Friend of Wrox
 
Join Date: Jul 2003
Location: York, , United Kingdom.
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default

All of the methods you mentioned will work, however they are not optimised for performance.

This doesn't matter if you're just creating one string. However, for a large number of string operations (say string concatenation in a large loop), you'd be better off using one of the following methods:

Method 1
--------
Code:
Dim s As String
s = String.Format ("{0}{1}{2}", _
        "This is a long line of text ", _
        "that I would really like to ", _
        "break up on multiple lines")
Method 2
--------
Code:
Dim s As String
Dim sb As New System.Text.StringBuilder

sb.Append("This is a long line of text ")
sb.Append("that I would really like to ")
sb.Append("break up on multiple lines")
s = sb.ToString
However, as I said, the performance hit from doing a concatenation such as
Code:
S = "This is a long line of text " & _
    "that I would really like to " & _
    "break up on multiple lines"
is pretty minimal. As I said, just don't put it in a big loop.