I am attempting to resize a 3D array in C#.
The VB6 code reads:
ReDim Combos(ProductNum, 4, 3)
Since I cannot use Array.Resize for a 3D array, is there another way for me to do this function in C#?
I have already declared the array as a 3D array:
int[ , , ] Combos;
But I am having trouble resizing it. Any ideas?
There is no way to directly redimension a multidimensional array in .NET. I would recommend allocating a new array, and then copying the values into it using
Array.Copy.That being said, depending on what you’re doing, you may want to consider using a different collection type, as well. There are more options in .NET than VB6 in terms of collections, so many cases which used multidimensional arrays are better suited towards other collection types, especially if they are going to be resized.