Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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 DimensionTest
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[][][] test = {
  14.                 new string[][] {
  15.                     new string[] { "AA", "AB" }, new string[] { "BA", "BB" }
  16.                 },
  17.                 new string[][] {
  18.                     new string[] { "CA", "CB" }, new string[] { "DA", "DB"  }
  19.                 }
  20.             };
  21.             string[][] test2 = { new string[] { "A" },
  22.                                  new string[] { "B" },
  23.                                  new string[] { "C" },
  24.                                  new string[] { "D" } };
  25.             IterateArray(test, "test");
  26.             IterateArray(test2, "test2");
  27.             Console.ReadLine();
  28.         }
  29.  
  30.         static void IterateArray(Array arr, string name)
  31.         {
  32.             Console.WriteLine("Iterating \"" + name + "\"");
  33.             Iterate(arr);
  34.         }
  35.  
  36.         static void Iterate(Array arr)
  37.         {
  38.             if (arr is string[])
  39.                 foreach (string s in arr)
  40.                     Console.WriteLine(s);
  41.             else
  42.                 foreach (Array sub in arr)
  43.                     Iterate(sub);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement