You can use the Length property of an array to get the number of elements in the array.
For a one- or multi-dimensional arrays, the length is always the total number of elements. For a jagged array (array of arrays), the length is the number of elements in the outer dimension.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int[] someNumbers = { 5, 16, 12, 38, 78, 63 };// Length = 6Console.WriteLine(someNumbers.Length);int[,] twoDimensional = { { 3, 2, 1 }, { 1, 2, 3 }, { 4, 6, 8 } };// Length = 9Console.WriteLine(twoDimensional.Length);int[][] jagged = new int[3][] { new int[] { 1, 2, 3 }, new int[] { 4, 8 }, new int[] { 10, 20, 30, 40 } };// Length = 3Console.WriteLine(jagged.Length); |

