Guest User

Untitled

a guest
Jan 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. static int[] split(ref int[] array, int len) {
  2. int[] buffer1 = new int[len];
  3. int[] buffer2 = new int[array.Length - len];
  4.  
  5. Array.Copy(array, buffer1, buffer1.Length);
  6. Array.Copy(array, len, buffer2, 0, buffer2.Length);
  7.  
  8. array = buffer2;
  9. return buffer1;
  10. }
  11.  
  12. int[] numbers = {1,2,3,4,5};
  13. int[] begining = split(ref numbers, 3);
  14.  
  15. foreach (int i in begining)
  16. Console.Write(i + " ");
  17. Console.Write(" ");
  18. foreach (int i in numbers)
  19. Console.Write(i + " ");
  20.  
  21. /* out:
  22. 1 2 3 4 5
  23. */
Add Comment
Please, Sign In to add comment