473,323 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Usage of EnsureCapacity for a string data type

Roy
Hi all,

I understand the definition of this property, but I'm not sure when or why
it should be used.
Thanks in advnace

Roy
Jul 21 '05 #1
1 1645
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
Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JT | last post by:
i don't know why i can't find this anywhere but - what is the maximum number of characters that a string variable can hold - i initially thought it was 256, but after some testing it seems that...
8
by: Newsnet Customer | last post by:
Hi, Which system header file do I unclude in order to use the new string data type? KJ
4
by: MrMike | last post by:
I'm working with a DataGrid UpdateCommand event and running into a problem. The second column of the dg is the PK named "FlitchNum". The datatype of this PK is varchar(string). In the event I...
6
by: tvn007 | last post by:
Hi, I tried to convert string data type to char type so that I can use strtok. I have used c_str(). However, still getting error message when compile . Any help would be appreciate.
6
by: John Aldrin | last post by:
Hi, I'm looking for info that explains the format of a string data type when written to a stream using a BinaryWriter. I've looked all over MSDN and Internet and I cannot seem to find it. I...
3
by: Steve Holland | last post by:
Can a variable declared as string (Dim strMessage as String) be set to a Null value??? If so, how??? I am using SQL Server as a backend database and want to set values not populated on a VB.Net...
1
by: Roy | last post by:
Hi all, I understand the definition of this property, but I'm not sure when or why it should be used. Thanks in advnace Roy
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.