By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,422 Members | 1,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,422 IT Pros & Developers. It's quick & easy.

Getting the dimensions of a multidimensional array

P: n/a
A colleague has just showed me the [,] syntax that introduces
multidimensional arrays (as opposed to jagged arrays, which are similar
to C++ arrays).

So we defined such an array:
int[,] a= new [,]{{1,2},{3,4},{5,6}}
wonderful syntax, especially since "new" is used only once.

Anyhow, we were a little surprised to see that
a.Length
evaluates to 6.

That's logical in some way, but how can I find the max indices to be
used on each dimension? (in this case 3 and 2)
Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Durior <no*******@noserver.com> wrote:
A colleague has just showed me the [,] syntax that introduces
multidimensional arrays (as opposed to jagged arrays, which are similar
to C++ arrays).

So we defined such an array:
int[,] a= new [,]{{1,2},{3,4},{5,6}}
wonderful syntax, especially since "new" is used only once.

Anyhow, we were a little surprised to see that
a.Length
evaluates to 6.

That's logical in some way, but how can I find the max indices to be
used on each dimension? (in this case 3 and 2)


Yup - look at Array.GetLength(int dimension)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.