471,319 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

Multidimension Array in C# Windows Form

Hi,

I have a 2 dimension string array MyArray, how do I know the Count of the
Rows and Columns in the MyArray?
Thanks for help.
Jason
Jan 19 '06 #1
5 4441
is it a staggered array or a rectangular array?
By this, I mean, have you declared it as:

string[][] MyArray (staggered)
or
string[,] MyArray (rectangular)

Jan 19 '06 #2
Thanks Steven,
I declare it as string[ , ] GoodString;
"Steven Nagy" <le*********@hotmail.com>
???????:11**********************@g49g2000cwa.googl egroups.com...
is it a staggered array or a rectangular array?
By this, I mean, have you declared it as:

string[][] MyArray (staggered)
or
string[,] MyArray (rectangular)

Jan 19 '06 #3
Jason Huang wrote:
Thanks Steven,
I declare it as string[ , ] GoodString;


In that case use GoodString.GetUpperBound(0) to get the upper bound for
the first dimension, and GoodString.GetUpperBound(1) to get the upper
bound for the second dimension.

Jon

Jan 19 '06 #4
Yes, as Jon suggests...

string[ , ] GoodString;
....
int count = GoodString.GetUpperBound(0) * GoodString.GetUpperBound(1);

Jan 19 '06 #5
Steven Nagy <le*********@hotmail.com> wrote:
Yes, as Jon suggests...

string[ , ] GoodString;
...
int count = GoodString.GetUpperBound(0) * GoodString.GetUpperBound(1);


To get the total size is easier than that - just use GoodString.Length.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Geoff Cox | last post: by
11 posts views Thread by Geoff Cox | last post: by
1 post views Thread by Manny Chohan | last post: by
11 posts views Thread by Zorpiedoman | last post: by
21 posts views Thread by yeti349 | last post: by
29 posts views Thread by foker | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.