J
Jon
Thanks for the explanation. I have a string in some code that is used to display messages in a text
box, and I keep appending new messages to it. It sounds like I should be using stringbuilder.
Jon
It's actually a regular String object.
The StringBuilder internally treats it as a mutable string buffer while
working on it, but when you get it from the ToString method it's just a
regular string.
The StringBuilder keeps track of the status of the string, so that if
you have used ToString to get the buffer as a string and keep making
changes the StringBuilder, it can no longer change the current buffer
(as it's used as an immutable string outside the StringBuilder), so it
has to copy the data to a new buffer.
box, and I keep appending new messages to it. It sounds like I should be using stringbuilder.
Jon
Göran Andersson said:What is a string wrapper? Is that a reference to the string that stringbuilder has manipulated?
It's actually a regular String object.
The StringBuilder internally treats it as a mutable string buffer while
working on it, but when you get it from the ToString method it's just a
regular string.
The StringBuilder keeps track of the status of the string, so that if
you have used ToString to get the buffer as a string and keep making
changes the StringBuilder, it can no longer change the current buffer
(as it's used as an immutable string outside the StringBuilder), so it
has to copy the data to a new buffer.