Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
String vs. StringBuilder
Message
From
30/05/2003 09:33:32
 
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
String vs. StringBuilder
Miscellaneous
Thread ID:
00794481
Message ID:
00794481
Views:
44
I know that when many operations are performed on a string or strings such as in a large loop, a StringBuilder should be used isntead of a String. However, what I am curious about is if this applies to creating a single string object from a set of known concatenated strings in a single statement.

E.g., if we have 20 fields on a form and want to create a single string containing all of the values, we could do something like:
string MyString = "Field1: " + this.MyField1.Text + "\r\n" +
                  "Field2: " + this.MyField2.Text + "\r\n" +
                  "Field3: " + this.MyField3.Text + "\r\n" +
                  ...
                  "Field20: " + this.MyField20.Text
Since all of the data is concatenated into the single string in one statement, does the rule to use a StringBuilder for multiple operations apply in this case?

Thanks
Bill
William A. Caton III
Software Engineer
MAXIMUS
Atlanta, Ga.
Next
Reply
Map
View

Click here to load this message in the networking platform