✅ GetLength vs .Length

   static void Main(string[] args)
   {
       int[,,] ints = new int[,,] {

          { {1,2,3},
            {4,5,6},
            {7,8,9} },
          {
           {10,10,11},
           {11,12,13},
           {12,13,14}
           
           }

          
       };
       for (int i = 0; i < ints.GetLength(0); i++)
       {
           for (int j = 0; j < ints.GetLength(1); j++)
           {
               for(int k = 0; k < ints.GetLength(2); k++)
               {
                   Console.WriteLine(ints[i, j, k]);
               }
           }
       }
       Console.ReadLine();
   } 


the thing is .GetLength(0) doesn't need a -1 in the end while in .Length we do it like .Length-1
Was this page helpful?