I am trying to find the fastest way to return a part of an array in C# My current way is as follows:
// .. set int moveCount ..
// .. set int[] childArray ..
int[] realArray = new int[moveCount];
Array.Copy(childArray, realArray, moveCount);
return realArray;
This is the way I see it everywhere on the net, but I wonder if the array will be copied twice now. Once because I do it, and once because of returning.
- Is this a right assumption?.
- Is there a better way? I know about Buffer.BlockCopy.