string class - memory reallocation

D

Dmitri Shvetsov

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.
 
K

Karin

From what I have learned System.Text.StringBuilder is the way to go when
maipulating strings.

/K
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top