What will be the C# equivalent of the following ReDim a(0 To i, 0 To 1)
?
I am trying to implement using it by Array.resize ... but it's not working.
What will be the C# equivalent of the following ReDim a(0 To i, 0 To 1)
?
I am trying to implement using it by Array.resize ... but it's not working.
Since you aren't using Preserve
, this is just:
a = new SomeType[i,1];
More generally Array.Resize
(which is akin to ReDim Preserve
) only works on vectors (1-dimensional 0-based arrays); there is not an overload for multi-dimensional arrays. You can, however, simply create a new array and then copy the data from the old array to the new array in a loop. However, frankly if you are routinely resizing arrays, then something might be wrong in your code - maybe consider some kind of nested list; or since your second direction is always 0-1, either two separate arrays/lists, or a single array/list of a type with two members.