© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
11 replies
Muhammad Hammad

✅ 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();
   } 
   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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

LibVLC - Audio Length
C#CC# / help
4mo ago
❔ char utf16-length
C#CC# / help
3y ago
Help with get Length
C#CC# / help
8mo ago
troubles with list length
C#CC# / help
4y ago