Friends,
I have a method to resize a two-dimensional array in C#. I'm trying to transform this method to C++ Winforms.
I've tried several times but I'm not succeeding. Follow the method and method call in C#
At the beginning of the program, I define a matrix with 1 line and 6 columns like string.
I call a method that reads a database and populates a dataset. From there, I call the method passing the array name by reference, the number of rows, and the number of columns.
As record insertions occur, I need to resize the array. At that time I call the method passing the original matrix called todoagenda;
I do this with two more matrices. I call the same method but passing different matrices.
void ResizeArray<T>(ref T[,] original, int x, int y)
{
T[,] newArray = new T[x, y];
int minX = Math.Min(original.GetLength(0), newArray.GetLength(0));
int minY = Math.Min(original.GetLength(1), newArray.GetLength(1));
for (int i = 0; i < minY; ++i)
Array.Copy(original, i * original.GetLength(0), newArray, i * newArray.GetLength(0), minX);
original = newArray;
}
The call is:
ResizeArray<String>(ref todaagenda, TotReg, 7); // resize the array to the new size