Can ArrayCopy function work for 2 dimensional array too ?

To add comments, please log in or register
Young Ho Seo
34544
Young Ho Seo  

Hello fellow coders

Can ArrayCopy function be used for 2 dimensional array too ?

The code below does not provide me any error on Meta Editor and compiling wise, it was fine. However, just curious if the ArrayCopy function is meant to be used for 2 dimensional array too.

ArrayCopy(array1, array2, 0, 0, WHOLE_ARRAY);


Sharing your thought will be really appreciated.

Kind regards.

Stuart Browne
7452
Stuart Browne  

Hi FE

Somewhere in the back of my mind I remember reading that it only copies the first dimension but I could be wrong. Should be fairly easy to test it in a debug....? If not, a nested loop should do the trick. I'd be interested to hear your results.

Young Ho Seo
34544
Young Ho Seo  
Filter:

Hi FE

Somewhere in the back of my mind I remember reading that it only copies the first dimension but I could be wrong. Should be fairly easy to test it in a debug....? If not, a nested loop should do the trick. I'd be interested to hear your results.


Just testing now. So I will know the results quite soon. :)

Young Ho Seo
34544
Young Ho Seo  

I did not throughly tested ArrayCopy yet. However I did remember that the results did look seemingly wrong when I use ArrayCopy for 2d array. So I just replace ArrayCopy to this code below for safety.

    for(int i = 0; i < m; i++)
        for(int j = 0; j < n; j++)
            newmatrix[i][j] = oldmatrix[i][j];
    
Stuart Browne
7452
Stuart Browne  
Thanks for the update mate
Young Ho Seo
34544
Young Ho Seo  
Filter:
Thanks for the update mate
No prob.  :)
To add comments, please log in or register