String and StringBuilder



Posted By: Anonmous (Email Hidden)

Date Posted: 12/26/2010

Descriptions:

What is the difference between String and StringBuilder?

Responses

Posted By
Anonymous

Date: 12/26/2010

      
Both String and StringBuilder are classes used to handle strings.

The most common operation with a string is concatenation. This activity has to be performed very efficiently. When we use the "String" object to concatenate two strings, the first string is combined to the other string by creating a new copy in the memory as a string object, and then the old string is deleted. This process is a little long. Hence we say "Strings are immutable".

When we make use of the "StringBuilder" object, the Append method is used. This means, an insertion is done on the existing string. Operation on StringBuilder object is faster than String operations, as the copy is done to the same location. Usage of StringBuilder is more efficient in case large amounts of string manipulations have to be performed.


Post Reply
   
Quick Links for Forum Categories:  
   
ASP.Net C# .NET Framework VB.Net Sql Server SharePoint
OOPs Silverlight IIS JQuery JavaScript Biztalk
WPF Patten/Practices WCF Others SSRS SSIS
SSAS WF Cloud Java HTML5 CSS3
Android Windows8 Metro
 
 
Post Article  Post Code 
  Post Tip    Start Forum
 
Quick note for developers
Google+
Follow