By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,666 Members | 1,413 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,666 IT Pros & Developers. It's quick & easy.

string class - memory reallocation

P: n/a
Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++
this step to make it significantly more so that this string could change the
memory reallocation only ones and then we could append more strings without
memory reallocation at all just inserting our characters beginning from the
last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long
strings? What I see right now - is very long work with strings and as longer
the strings as more annoying is this work.

Regards,
Dmitri.
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
From what I have learned System.Text.StringBuilder is the way to go when
maipulating strings.

/K

"Dmitri Shvetsov" <ds*******@cox.net> wrote in message
news:a6bPa.1210$_s.912@fed1read03...
Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++ this step to make it significantly more so that this string could change the memory reallocation only ones and then we could append more strings without memory reallocation at all just inserting our characters beginning from the last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long strings? What I see right now - is very long work with strings and as longer the strings as more annoying is this work.

Regards,
Dmitri.

Nov 13 '05 #2

P: n/a
No, but StringBuilder is there for the kind of purposes you want.

S.

"Dmitri Shvetsov" <ds*******@cox.net> wrote in message
news:a6bPa.1210$_s.912@fed1read03...
Hi All,

Does somebody know how to work with this class directly? I know that we
could redefine some internal predefined variables in C++ to force some
methods to run much faster. For example. If you use "string sOldString +=
sNewString;" in a loop the string class has to reallocate the memory each
time to insert the summarized string inside the new block of memory, then
copies this original string and appends a new string. We could change in C++ this step to make it significantly more so that this string could change the memory reallocation only ones and then we could append more strings without memory reallocation at all just inserting our characters beginning from the last position and having the reserve for this append. Can we use the same
trick in C# to increase the speed of the application working with very long strings? What I see right now - is very long work with strings and as longer the strings as more annoying is this work.

Regards,
Dmitri.

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.