Search All Articles Submit your Website or Blog to A New Internet Library
Friday, April 9, 2010
What is the difference between System.Text.StringBuilder and System.String?
String is immutable and string builder is mutable.
String is useful as some costly operations for copying and comparing can be omitted making program simple.
However, making an object immutable is usually inappropriate if the object contains a large amount of changeable data.
So String is not suggested to hold huge data as replacements or concatinations will be costly and time consuming.
Copying is simple using reference. Whereas reference copying technique (Copying data without pointing to the same reference) is difficult in case of StringBuilder.
String will allocate only what is needed. When we concatinate strings, it sums up the length of all and creates buffer to fit that.
Whereas string builder allocates capacity of 16 initially and increases capacity in the multiples of 2.
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.


0 comments:
Post a Comment
Post your comments/questions/feedback for this Article.