473,763 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why isn't there an StringBuilder.A ppend overload with StringBuilder as argument?

Why isn't there an StringBuilder.A ppend() overload with a StringBuilder as
argument?
Is there a reason that I missed?
Jul 22 '05 #1
9 1839
I think there isn't because it would be useless. Now you can do:

....
stringBuilder2. Append(stringBu ilder1.ToString ());
....

I find no reason why one need such method.
"cody" <de********@gmx .de> escribió en el mensaje
news:eG******** ******@TK2MSFTN GP10.phx.gbl...
Why isn't there an StringBuilder.A ppend() overload with a StringBuilder as
argument?
Is there a reason that I missed?

Jul 22 '05 #2
> I think there isn't because it would be useless. Now you can do:

...
stringBuilder2. Append(stringBu ilder1.ToString ());
...

I find no reason why one need such method.


Your "reason" would make all of the existing 19 overloads of StringBuilder
"useless".
The problem is that stringBuilder1. ToString() creates a new string which I
want to avoid.
Jul 22 '05 #3
How do you build the other one ? You could perhaps reuse it ie. using a
single string builder rather than creating separately two of them and then
combining them ?
--

"cody" <de********@gmx .de> a écrit dans le message de
news:eU******** ******@TK2MSFTN GP14.phx.gbl...
I think there isn't because it would be useless. Now you can do:

...
stringBuilder2. Append(stringBu ilder1.ToString ());
...

I find no reason why one need such method.
Your "reason" would make all of the existing 19 overloads of

StringBuilder "useless".
The problem is that stringBuilder1. ToString() creates a new string which I
want to avoid.

Jul 22 '05 #4
Sure I could do that. But Iam asking why StringBuilder doesn't support that.
There must be a technical reason. Maybe it has something to do with
threadsafety.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:u5******** ******@TK2MSFTN GP10.phx.gbl...
How do you build the other one ? You could perhaps reuse it ie. using a
single string builder rather than creating separately two of them and then
combining them ?
--

"cody" <de********@gmx .de> a écrit dans le message de
news:eU******** ******@TK2MSFTN GP14.phx.gbl...
I think there isn't because it would be useless. Now you can do:

...
stringBuilder2. Append(stringBu ilder1.ToString ());
...

I find no reason why one need such method.


Your "reason" would make all of the existing 19 overloads of

StringBuilder
"useless".
The problem is that stringBuilder1. ToString() creates a new string which I want to avoid.


Jul 22 '05 #5
StringBuilder works internally with a large string, inserting data at an
incrementing position. For example, Append(bool value) calls return
this.Append(val ue.ToString()), where Append(string value) does the real
appending. Append(object value) works in the same way.

So if there would be a Append(StringBu ilder value), it would internally
still call Append(value.To String()), thus making it equal to call
Append(myString Builder.ToStrin g()).

cody wrote:
Why isn't there an StringBuilder.A ppend() overload with a StringBuilder as
argument?
Is there a reason that I missed?

Jul 22 '05 #6
Simon Svensson <ta*****@tant10 2.mine.nu> wrote:
StringBuilder works internally with a large string, inserting data at an
incrementing position. For example, Append(bool value) calls return
this.Append(val ue.ToString()), where Append(string value) does the real
appending. Append(object value) works in the same way.

So if there would be a Append(StringBu ilder value), it would internally
still call Append(value.To String()), thus making it equal to call
Append(myString Builder.ToStrin g()).


Not quite equal - after calling myStringBuilder .ToString(), any appends
to myStringBuilder have to create a new string, whereas with suitable
support in StringBuilder, that wouldn't be necessary.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 22 '05 #7
Rather conceptual than technical IMO. It was just intended to build a whole
string using a single StringBuilder ;-)

For example if you push further the use of several stringbuilders and
merging them, you are on a path that is not that different to the initial
situation for strings (you'll finally ends up with copying strings to a
memory location just to move them at some other place shortly).

--
Patrice

"cody" <de********@gmx .de> a écrit dans le message de
news:ut******** ******@TK2MSFTN GP14.phx.gbl...
Sure I could do that. But Iam asking why StringBuilder doesn't support that. There must be a technical reason. Maybe it has something to do with
threadsafety.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:u5******** ******@TK2MSFTN GP10.phx.gbl...
How do you build the other one ? You could perhaps reuse it ie. using a
single string builder rather than creating separately two of them and then
combining them ?
--

"cody" <de********@gmx .de> a écrit dans le message de
news:eU******** ******@TK2MSFTN GP14.phx.gbl...
> I think there isn't because it would be useless. Now you can do:
>
> ...
> stringBuilder2. Append(stringBu ilder1.ToString ());
> ...
>
> I find no reason why one need such method.

Your "reason" would make all of the existing 19 overloads of StringBuilder
"useless".
The problem is that stringBuilder1. ToString() creates a new string

which I want to avoid.



Jul 22 '05 #8
Maybe you're right, it sounds quite logical, but I suspect there are
situations where it actually could be useful.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:uA******** ******@TK2MSFTN GP15.phx.gbl...
Rather conceptual than technical IMO. It was just intended to build a whole string using a single StringBuilder ;-)

For example if you push further the use of several stringbuilders and
merging them, you are on a path that is not that different to the initial
situation for strings (you'll finally ends up with copying strings to a
memory location just to move them at some other place shortly).

--
Patrice

"cody" <de********@gmx .de> a écrit dans le message de
news:ut******** ******@TK2MSFTN GP14.phx.gbl...
Sure I could do that. But Iam asking why StringBuilder doesn't support

that.
There must be a technical reason. Maybe it has something to do with
threadsafety.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:u5******** ******@TK2MSFTN GP10.phx.gbl...
How do you build the other one ? You could perhaps reuse it ie. using a single string builder rather than creating separately two of them and then combining them ?
--

"cody" <de********@gmx .de> a écrit dans le message de
news:eU******** ******@TK2MSFTN GP14.phx.gbl...
> > I think there isn't because it would be useless. Now you can do:
> >
> > ...
> > stringBuilder2. Append(stringBu ilder1.ToString ());
> > ...
> >
> > I find no reason why one need such method.
>
> Your "reason" would make all of the existing 19 overloads of
StringBuilder
> "useless".
> The problem is that stringBuilder1. ToString() creates a new string

which
I
> want to avoid.
>
>



Jul 22 '05 #9
Have you checked ToString ? Unless you abuse it it should be still quite
quick anyway (this is *repeated* allocations that kills you with strings so
a single copy shouldn't be that harmfull).

You could easily compare the ToString approach and the single StringBuilder
approach and see if it makes a difference in your case...

Happy coding...
--

Patrice

"cody" <de********@gmx .de> a écrit dans le message de
news:Of******** ******@TK2MSFTN GP12.phx.gbl...
Maybe you're right, it sounds quite logical, but I suspect there are
situations where it actually could be useful.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:uA******** ******@TK2MSFTN GP15.phx.gbl...
Rather conceptual than technical IMO. It was just intended to build a whole
string using a single StringBuilder ;-)

For example if you push further the use of several stringbuilders and
merging them, you are on a path that is not that different to the initial
situation for strings (you'll finally ends up with copying strings to a
memory location just to move them at some other place shortly).

--
Patrice

"cody" <de********@gmx .de> a écrit dans le message de
news:ut******** ******@TK2MSFTN GP14.phx.gbl...
Sure I could do that. But Iam asking why StringBuilder doesn't support

that.
There must be a technical reason. Maybe it has something to do with
threadsafety.
"Patrice" <no****@nowhere .com> schrieb im Newsbeitrag
news:u5******** ******@TK2MSFTN GP10.phx.gbl...
> How do you build the other one ? You could perhaps reuse it ie.
using a > single string builder rather than creating separately two of them

and then
> combining them ?
> --
>
> "cody" <de********@gmx .de> a écrit dans le message de
> news:eU******** ******@TK2MSFTN GP14.phx.gbl...
> > > I think there isn't because it would be useless. Now you can do:
> > >
> > > ...
> > > stringBuilder2. Append(stringBu ilder1.ToString ());
> > > ...
> > >
> > > I find no reason why one need such method.
> >
> > Your "reason" would make all of the existing 19 overloads of
> StringBuilder
> > "useless".
> > The problem is that stringBuilder1. ToString() creates a new string

which
I
> > want to avoid.
> >
> >
>
>



Jul 22 '05 #10

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

Similar topics

20
1899
by: Alvin Bruney | last post by:
On the advice of a user, I've timed stringbuilder v string. Here are the results. Here are the numbers: Total # queries 3747 Time in Milliseconds StringBuilder: String 460.6624 320.4608 350.504 220.3168
12
7398
by: | last post by:
I know how to use a StringBuilder, which supposedly does not create a new copy of it each time you modify it contents by adding or removing text. But, I wonder how does it do that internally ? I was planning to use a stringbuilder to hold big amounts of text, with several megs o size, to be read later based on fixed offsets, so I need to know if this is suitable for it.
14
15048
by: Bob | last post by:
I have a function that takes in a list of IDs (hundreds) as input parameter and needs to pass the data to another step as a comma delimited string. The source can easily create this list of IDs in a comma-delimited string or string array. I don't want it to be a string because I want to overload this function, and it's sister already uses a string input parameter. Now if I define the function to take in a string array, it solves my...
1
6183
by: Sagaert Johan | last post by:
Hi I am construncting a string containing some control chars (STX/ETX) I noticed that adding a byte with value 2 is the same as adding a character '2' ??? How can i solve this problem ? Is the stringbuilder restricted to pure readable ascii code contents ?
3
2293
by: todorov-fkt | last post by:
Hello Provided the following code: string temp = "Short string"; // 12 chars StringBuilder sb = new StringBuilder(); sb.Append(temp, 0, 30); How many characters is the string in sb? 12 or is it filled with blanks to reach 30 chars?
6
7826
by: Paulb1us | last post by:
I am writing a DataTable to a file using a stringbuilder. The Format of the date in the table is like this: '12/20/04' But after I write it to the file it ads the time: '12/20/04 12:00:00 AM' My code looks like this for(int curRow = 0; curRow < dt1.Rows.Count; curRow++) {
9
9158
by: Peter Row | last post by:
Hi, I know this has been asked before, but reading the threads it is still not entirely clear. Deciding which .Replace( ) to use when. Typically if I create a string in a loop I always use a StringBuilder. At present I am porting a VB6 webclass app to VB.NET and therefore I am trying to make it as efficent as possible via the new functionality of VB.NET.
9
283
by: cody | last post by:
Why isn't there an StringBuilder.Append() overload with a StringBuilder as argument? Is there a reason that I missed?
8
3796
by: Soulless | last post by:
I am trying to implement the stringbuilder class by taking a LARGE multiline text box and looping through the lines and build a string and include \r\n in it. I get : Index was outside the bounds of the array. The code is simply: StringBuilder str = new StringBuilder();
0
9566
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9389
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9943
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8825
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7370
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3918
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.