C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

String Concatenation in ASP.NET


Posted Date: 01 Sep 2007    Resource Type: Articles    Category: .NET Framework
Author: KamalMember Level: Gold    
Rating: 1 out of 5Points: 10



An example of how strings can be concatenated with the StringBuilder class

If you concatenate a string like this:

Dim s As String = ""
s &= "This "
s &= "is "
s &= "an "
s &= "example "
Label1.Text = s

Dim s As String = ""
s &= "This "
s &= "is "
s &= "an "
s &= "example "
Label1.Text = s

then you actually end up with 5 strings in memory rather than just the original one that you created. This obviously isn't very efficient.

Instead, you can use the System.Text.StringBuilder class which is both quicker and uses less memory as only one object is created:

Dim sb As New StringBuilder
sb.Append("This ")
sb.Append("is ")
sb.Append("an ")
sb.Append("example")
Label1.Text = sb.ToString()



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: ASP.NET HyperLink & Mailto In Details View
Previous Resource: Using a Thread Pool in C# for Multiple Currency Conversion
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use