Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int[] split(ref int[] array, int len) {
- int[] buffer1 = new int[len];
- int[] buffer2 = new int[array.Length - len];
- Array.Copy(array, buffer1, buffer1.Length);
- Array.Copy(array, len, buffer2, 0, buffer2.Length);
- array = buffer2;
- return buffer1;
- }
- int[] numbers = {1,2,3,4,5};
- int[] begining = split(ref numbers, 3);
- foreach (int i in begining)
- Console.Write(i + " ");
- Console.Write(" ");
- foreach (int i in numbers)
- Console.Write(i + " ");
- /* out:
- 1 2 3 4 5
- */
Add Comment
Please, Sign In to add comment