none
Length of a Multi-Dimensional Array RRS feed

Answers

  • Why don't you ask C# itself? The following code prints 3 different answers, pick whichever you consider to be length in this case:

                int[,] n6 = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
    
                Console.WriteLine(n6.Length); // this says 6
                Console.WriteLine(n6.GetLength(0)); // this says 3
                Console.WriteLine(n6.GetLength(1)); // and this says 2
    

    • Proposed as answer by Norkk Tuesday, September 18, 2012 6:30 PM
    • Marked as answer by Raymond Cheyne Tuesday, September 18, 2012 6:43 PM
    Tuesday, September 18, 2012 6:29 PM
    Moderator

All replies