Advertisement
NedyalkoKikov

CopyArrToAnotherArr

Jun 1st, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ArrayCopy
  8. {
  9. class ArrayCopy
  10. {
  11. static void Main()
  12. {
  13. int[] source = new int[5];
  14. source[0] = 2;
  15. source[1] = 3;
  16. source[2] = 4;
  17. source[3] = 5;
  18. source[4] = 6;
  19. for (int i = 0; i < source.Length; i++)
  20. {
  21. Console.WriteLine(source[i]);
  22. }
  23. int[] target = new int[5];
  24. Array.Copy(source, target, 5);
  25. Console.WriteLine("Copied elements from source to target:");
  26. for (int i = 0; i < target.Length; i++)
  27. {
  28. Console.WriteLine(target[i]);
  29. }
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement