How the StringBuilder class is implemented? Does it internally create new string objects each time we append?
How the StringBuilder class is implemented? Does it internally create new string objects each
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In .NET 2.0 it uses the
Stringclass internally.Stringis only immutable outside of theSystemnamespace, soStringBuildercan do that.In .NET 4.0
Stringwas changed to usechar[].In 2.0
StringBuilderlooked like thisBut in 4.0 it looks like this:
So evidently it was changed from using a
stringto using achar[].EDIT: Updated answer to reflect changes in .NET 4 (that I only just discovered).