Valhalla Legends Forums Archive | .NET Platform | Getting the upper bound of a array on a array (vb)

AuthorMessageTime
Zeller
I made an array that holds arrays of strings. ex:

[code]
dim myArray(100)() as string
for i = 0 to 100
myArray(i) = textbox1.split("Y")
next
[/code]

Now in my real program each string array of strings would be a different size.

The problem im having is getting the upper bound of the second array (the array already on the array). Can some one post an example on how to retrieve it
January 30, 2004, 12:19 AM
drivehappy
[code]
myArray.GetUpperBound(i)
[/code]
January 30, 2004, 1:37 AM
Zeller
That function returns the upper bound for a single multidimensional array. If you looked, both arrays only have 1 dimension.
January 30, 2004, 1:57 AM
Zeller
Anyway I decided to solve the problem by putting my arrays in an arraylist object so I dont need help anymore.
January 30, 2004, 2:13 AM
Myndfyr
For future reference....

Drivehappy was close. We need to realize that when utilizing a two-dimensional array, we can really envision an array of arrays.

So, you could do something like:

[code]
Dim i As Integer
For i = 0 to 100
Console.WriteLine("Line length {0}, Upper boundary {1}.", myArray(i).Length, myArray(i).Length - 1)
Next
[/code]

Why add yet another level of indirection when you can use something rather fast and simple?
January 30, 2004, 2:59 AM
Zeller
I guess that would work, I never saw a length used like that (exept when debugging). +1 for you ;)

btw I honestly did not understand you last sentence
January 30, 2004, 5:07 AM
Myndfyr
What I meant was that with an arraylist, you will end up adding another reference type, and hence essentially another pointer, and thus another level of indirection. Those take more time to access than simply using arrays, because arrays just use the offset you specify.
January 30, 2004, 5:05 PM
Zeller
You still lost me with your pointers and indirection crap. If your trying to say using an arraylist would slow my program down, I can sacrafice a couple miliseconds
February 1, 2004, 8:25 AM

Search