Let's say I have an array of integers and attempt to do a call to CopyTo() onto a different array:
int[] a = {1, 2, 3};
int[] b = new int[3];
a.CopyTo(b, 0); // does b have a completely new set of { 1, 2, 3 }?
CopyTo() does a shallow copy, but I'm wondering, since int[] is a reference type, would this cause the elements within a to become boxed and thus no longer be value types?
Since you've created a new instance for array
bthe answer for your first question
is yes;
bdoesn't share the reference witha:Since you've created
bas an array ofint-int[]there will be no boxing.; all the items will be copied by values. If you want to play with boxing makebkeep items by reference:object[] b = new object[3];; if you want to see shallow copy make both arraysobjects[]: