Length of a multidimensional array

  • Thread starter Thread starter OpticTygre
  • Start date Start date
O

OpticTygre

If I have a multidimensional array, such as array1(5, 3), and I want to find
the length of the first section (the 5), can I just use array1.length, or
would that return 15 (5 * 3) instead of 5? Thanks in advance.
 
per documentation, it gets the total number of elements which in your case
would be 5*3 = 15 elements.

Imran.
 
What would be the easiest way of getting the length of a particular
dimension, be it x or y?
 
use Array.GetLength method which takes in the dimension as an argument.

Imran.
 
Hi,
its really simple:
for your array1(5,3)
5 is at your 0 dimension and 3 at 1
so writing
array1.getupperbound(0) will give u 5
and array1.getupperbound(0) will give u 3

hope that helps :-)
Abubakar.
http://joehacker.blogspot.com
 
you'll need to do array1.getupperbound - array1.getlowerbound to get the
length of the array (number of elements) which is what the OP was asking
for.

Imran.
 

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

Back
Top