> Kjellwrote:
Hi
I'm a former VB programmer and I have a issue with Arrays in C#
If I can't tell the size in advance how can I solve the issue since
C# does not support resizing arrays like VB do (i.e. Redim Preserve MyArray(x))
Kjell
As John said, an ArrayList may be more useful to you, but if you want
to change array sizes on the fly then here's an example from Instant
C#, the vb.net to C# converter:
VB Code:
Dim x() As Integer
ReDim Preserve x(3)
C# Code:
//INSTANT C# NOTE: The following 4 lines reproduce what 'ReDim
Preserve' does behind the scenes in VB.NET:
//ORIGINAL LINE: ReDim Preserve x(3)
int[] x = null;
int[] Temp1 = new int[4];
if (x != null)
System.Array.Copy(x, Temp1, x.Length);
x = Temp1;