Valhalla Legends Archive

Programming => General Programming => .NET Platform => Topic started by: Zeller on January 29, 2004, 06:19 PM

Title: Getting the upper bound of a array on a array (vb)
Post by: Zeller on January 29, 2004, 06:19 PM
I made an array that holds arrays of strings. ex:


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


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
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: drivehappy on January 29, 2004, 07:37 PM

myArray.GetUpperBound(i)
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: Zeller on January 29, 2004, 07:57 PM
That function returns the upper bound for a single multidimensional array. If you looked, both arrays only have 1 dimension.
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: Zeller on January 29, 2004, 08:13 PM
Anyway I decided to solve the problem by putting my arrays in an arraylist object so I dont need help anymore.
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: MyndFyre on January 29, 2004, 08:59 PM
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:


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


Why add yet another level of indirection when you can use something rather fast and simple?
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: Zeller on January 29, 2004, 11:07 PM
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
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: MyndFyre on January 30, 2004, 11:05 AM
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.
Title: Re:Getting the upper bound of a array on a array (vb)
Post by: Zeller on February 01, 2004, 02:25 AM
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