string class - memory reallocation

  • Thread starter Thread starter Dmitri Shvetsov
  • Start date Start date
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.
 
From what I have learned System.Text.StringBuilder is the way to go when
maipulating strings.

/K
 
Back
Top