Roy <Ro*@discussions.microsoft.com> wrote:
I understand the definition of this property, but I'm not sure when or why
it should be used.
Note that it's a method of StringBuilder, not String.
You would use this if you had a StringBuilder which already had a
certain capacity (i.e. you couldn't just create it with the right
capacity) but you knew that in the process of the next set of
operations, it would need to grow to at least a certain size. Using
EnsureCapacity makes the capacity grow in one go, rather than perhaps
involving several "jumps", each of which would need to copy data.
Basically, it's an optimisation thing - I don't think I've ever used
it, personally.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too