Question

I'm trying to get the count of items in one of the dimensions of a 2 dim array.

For example, a simplistic version of my array looks like this:

my_array(0)(1) = "a"
my_array(0)(2) = "b"
my_array(0)(3) = "c"

I'm trying to find out the count of items in my_array(0). But of course you can't do "my_array(0).count", so trying "my_array.count" simply gives me 1. So how do I get the count of the items in the second dimension?

Thanks.

Était-ce utile?

La solution

You can use GetLength:

Dim dimLength = my_Array.GetLength(1)

Autres conseils

If your looking for the count of every element in your array you might want to consider using the Sum function:

Dim totalcount As Integer = m_array.Sum(Function(x) x.Count)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top