473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

when there is stringbuilder, why string ?

Hi,

one question on why string is provided ?

stringbuilder offers more performance, less work for GC and good amount
of methods to manage text in it.

When there are many benefits with stringbuilder, why still string is
supported in framework ?

is it only for any compatibility and threadsafe nature of string ?

TIA
MeDhanush

Nov 17 '05 #1
3 1084
<me*******@yahoo.com> wrote:
one question on why string is provided ?

stringbuilder offers more performance, less work for GC and good amount
of methods to manage text in it.

When there are many benefits with stringbuilder, why still string is
supported in framework ?

is it only for any compatibility and threadsafe nature of string ?


No. Strings are immutable, which is invaluable. StringBuilders should
be used as their names suggest - to *build* strings. The final form
should be as a string though.

Note that it's not always more efficient to use StringBuilder, by the
way - see http://www.pobox.com/~skeet/csharp/stringbuilder.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Strings are also interned in a pool as in String.Intern(str).

Regards,
Jeff

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3
... and don't forget they are quite easy to use.

string s = "Hello World!"; //neat
string s = new StringBuilder().Append("Hello World!").ToString(); // yuk

Happy Coding
- Michael S
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: | last post by:
Hi! I'm very interesting in when to use exactly the StringBuilder? For example for something like this?: String strTest1 = "This"; String strTest2 = "Test"; StringBuilder stbTest = new...
9
by: Bjorn Abelli | last post by:
Hi all, When I run a normal application I can get who started a process with the following example: Process myProcesses = Process.GetProcesses(); foreach(Process p in myProcesses) {...
7
by: Mike P | last post by:
I read somewhere that if you are concatenating more than 2 or 3 strings you should use StringBuilder as it will use up less resources. Does this apply when you are building up a string (for...
4
by: Cor | last post by:
Hi Newsgroup, I have given an answer in this newsgroup about a "Replace". There came an answer on that I did not understand, so I have done some tests. I got the idea that someone said,...
8
by: Henning M | last post by:
Hi, I'm trying to use stringbuilder to collect a list of strings. (as suggested by Claes Bergefall) Declare Auto Function CM_Get_Device_ID_List Lib "cfgmgr32.dll" (ByVal pszFilter As String,...
12
by: Richard Lewis Haggard | last post by:
I thought that the whole point of StringBuilder was that it was supposed to be a faster way of building strings than string. However, I just put together a simple little application to do a...
26
by: Hardy Wang | last post by:
Hi all, I know it is better to handle large string with a StringBuilder, but how does StringBuilder class improve the performance in the background? Thanks! -- WWW:...
10
by: =?Utf-8?B?TWF0dA==?= | last post by:
I am using the following code to connect to and download files from an ftp server, but the Symantec anti-virus software on some of my customers machines tells them that their computers are...
34
by: raylopez99 | last post by:
StringBuilder better and faster than string for adding many strings. Look at the below. It's amazing how much faster StringBuilder is than string. The last loop below is telling: for adding...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.