Thread: When exactly should a StringBuilder be used?

  1. #1
    Registered User
    Join Date
    Oct 2002

    When exactly should a StringBuilder be used?


    I’m very interesting in when to use exactly the StringBuilder?

    For example for something like this?:

    String strTest1 = “This”;
    String strTest2 = “Test”;
    StringBuilder stbTest = new StringBuilder();
    stbTest.Append(strTest1). Append(“is a ”). Append(stbTest);

    can someone provide some sample codes when to use a StringBuilder?

    And can someone tell me his experience about the performance of a StringBuilder?



  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    System::String is optimized for static, non-changing strings. System::Text::StringBuilder is optimized for string operations like replacing, appending, deleting etc.

    If you are doing more with your string than just formatting it once, StringBuilder will be more efficient in speed and memory management.

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading Process Memory
    By polydegmon in forum C# Programming
    Replies: 0
    Last Post: 05-26-2009, 07:18 AM
  2. C# call Delphi DLL Error.
    By sergioms in forum C# Programming
    Replies: 14
    Last Post: 12-03-2008, 09:09 AM
  3. StringBuilder
    By C of Green in forum C# Programming
    Replies: 1
    Last Post: 11-18-2006, 10:15 AM
  4. Having a problem with string, not sure where to look
    By CompiledMonkey in forum C++ Programming
    Replies: 30
    Last Post: 11-26-2005, 06:47 PM