fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. int[][] array_of_arrays = new int[3][];
  8. int[] array_a = {1, 1, 1};
  9. int[] array_b = {2, 2, 2};
  10. int[] array_c = {3, 3, 3};
  11. array_of_arrays[0] = array_a;
  12. array_of_arrays[1] = array_b;
  13. array_of_arrays[2] = array_c;
  14.  
  15. print(array_of_arrays);
  16.  
  17. Console.WriteLine();
  18.  
  19. int[] temp = array_of_arrays[0];
  20. array_of_arrays[0] = array_of_arrays[1];
  21. array_of_arrays[1] = temp;
  22.  
  23. print(array_of_arrays);
  24. }
  25.  
  26. public static void print(int[][] a)
  27. {
  28. for (int i = 0; i < a.Length; i++) {
  29. if (a[i] == null) break;
  30.  
  31. for (int j = 0; j < a[i].Length; j++)
  32. Console.Write($"{a[i][j],2} ");
  33.  
  34. Console.WriteLine();
  35. }
  36. }
  37. }
  38.  
Success #stdin #stdout 0.07s 29224KB
stdin
Standard input is empty
stdout
 1  1  1 
 2  2  2 
 3  3  3 

 2  2  2 
 1  1  1 
 3  3  3