Alex Rivera | Logout

double[,] type, how to get the # of rows?

Asked 2009-03-24T15:27:17.283
10

I seem to be getting an odd value.

How do I get the number of rows in my array:

double[,] lookup = { {1,2,3}, {4,5,6} };

The output should be 2.

Edit
Report

1 Answer

3

You want the rank property on the array...

double[,] lookup = { { 1, 2, 3 }, { 4, 5, 6 } };
Console.WriteLine(lookup.Rank);

This will provide you with the number of dimensions.

Edit:
This will only provide you with the number of dimensions for the array as opposed to the number of primary elements or "rows" see @Henk Holterman's answer for a working solution.

answered 2009-03-24T15:31:02.030

Your Answer