473,398 Members | 2,212 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,398 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 1647
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.