Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I "Redim Preserve" in C#

Status
Not open for further replies.

JCruz063

Programmer
Feb 21, 2003
716
US
Hi All...

I'm new to C# coming from VB.
Visual Basic has a keyword named Redim [Preserve] that allows the programmer to resize an array (making it bigger) while preserving its current values. How can this be done in C#?

Thanks

Jose
 
AFAIK, you wouldn't.

Instead, you would use one of the built-in collection classes (Hashtable, etc).

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Thanks Chip...
I'm already using the ArrayList class. I wonder how efficient it is, though!

Jose
 
Why not add 100000 items to it and time how long it takes?

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
> I'm already using the ArrayList class. I wonder how efficient it is, though!

ArrayList 'redims' less frequently than you would in VB, if you did a redim on every add. If that was your pattern in VB, ArrayList is much more efficient.
 
It is right, the ArrayList is better than Redim.
One thing more is that ArrayList support multiple readers concurrently.

-obislavu-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top