Have you looked at the C # Array.Clone method ?
Edit: Actually, I believe Array.Copy could be more efficient / faster for your needs.
I did a quick test, and it seems that all changes in the destination do not affect the source:
int[] source = new int[3]{1,2,3}; int[] destination = new int[source.Length]; Array.Copy(source, destination, source.Length); destination[0]++;
leads to:
source = { 1 , 2 , 3 } destination = { 2, 2, 3 }
Is this the result you were looking for?
public static int[][] CopyArray(int[][] source) { int[][] destination = new int[source.Length][]; Array.Copy(source, destination, source.Length); return destination; }
basically fulfills what you seek, I believe.
Rion williams
source share