How many rows in my array object

K

Krish

How do you find out the number of rows in the array {Array}

I have [0,0]
[0,1]

[1,0]
[1,1]
.....

thanks
 
B

Bjorn Abelli

...
How do you find out the number of rows in the array {Array}

I have [0,0]
[0,1]

The concepts of "rows" and "columns" suggests only two-dimensional arrays,
but there can actually be many more.

To get the number of dimensions you can use

int dimensions = myArray.Rank;

To check how "big" each dimension is you have e.g. the method GetUpperBound
which takes the "dimension" as argument.

But let's say that you only have just two dimensions, and want to know how
many "rows" there are, you check the "first dimension":

int rows = myArray.GetUpperBound(0) + 1;

For other things you can do with an array:

http://msdn.microsoft.com/library/d...-us/cpref/html/frlrfSystemArrayClassTopic.asp

If the link above wrapped, try http://tinyurl.com/ywhb8


// Bjorn A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top