There is an equivalent - i.e., similar code to what VB is doing behind the
scenes and similar performance (produced with our Instant C# VB to C#
converter):
e.g.,
VB:
Dim YourArray() As Integer
....
ReDim Preserve YourArray(i)
C#:
int[] YourArray;
....
int[] temp = new int[i + 1];
if (YourArray != null)
Array.Copy(YourArray, temp, Math.Min(YourArray.Length, temp.Length));
YourArray = temp;
As the other poster said, ArrayList will very often be a better solution,
but at least you have the equivalent now.
--
David Anton
www.tangiblesoftwaresolutions.com
Home of:
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant J#: VB.NET to J# Converter
"Aleksey" wrote:
Hi All!
Does anybody know how can I change length of existing array. In Delphi I
used dynamic array and procedure SetLength. Is any similar procedure in C#.
For instance, I have array with 100 elements, and I need change its lenght
to 20 without lost data in it.
Thanks a lot