Create a copy of an integer array
Possible duplicate:
C #: Any faster way to copy arrays?
I have an integer array
int[] a;
I want to assign a copy of it (not a link) to
int[] b;
What's an easier way to do this?
+3
source to share
3 answers
You can use the method Array.CopyTo
.
int[] a = new[] { 1, 2, 3 };
int[] b = new int[3];
a.CopyTo(b,0);
+2
source to share