Fastest string manipulation object

  • Thread starter Thread starter Amendra
  • Start date Start date
A

Amendra

Hi,

Whats is the fastest object type or method that can be used for high
performance string manipulations. I have heard stringbuilder does. But does
any body know anything better.

My operation are simple.. this is what I need to do with a least performance
hit.

//_consoleMsg = new StringBuilder(message);

StringBuilder _consoleMsg = new StringBuilder();

// The below section will be called many times.

_consoleMsg.Append(message);

_consoleWindow.Console.Text = _consoleMsg.ToString();

Thanks

Amendra
 
Amendra,

I think that you should do neither. If all you are doing is displaying
the and don't have a need to store everything, then I would recommend
calling the AppendText method on the TextBox and appending the text to your
textbox using that.

Hope this helps.
 
Each time you AppendText it redisplays the text and re-allocates its
internal buffer. Serious performance issue. Stick to StringBuilder().


Thanks,
Shawn



Nicholas Paldino said:
Amendra,

I think that you should do neither. If all you are doing is displaying
the and don't have a need to store everything, then I would recommend
calling the AppendText method on the TextBox and appending the text to your
textbox using that.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Amendra said:
Hi,

Whats is the fastest object type or method that can be used for high
performance string manipulations. I have heard stringbuilder does. But does
any body know anything better.

My operation are simple.. this is what I need to do with a least performance
hit.

//_consoleMsg = new StringBuilder(message);

StringBuilder _consoleMsg = new StringBuilder();

// The below section will be called many times.

_consoleMsg.Append(message);

_consoleWindow.Console.Text = _consoleMsg.ToString();

Thanks

Amendra
 
Back
Top