Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Well, with all this talk of arrays and dynamic arrays and such, i did some looking.

 

now take for instance

 

Dim arrTXT(4) As Textbox
arrTXT(0) = txtFirstName
arrTXT(1) = txtLastName
'etc

Class.Method(arrTXT)

 

or

 

Dim arrTXT as Arraylist
arrTXT.Add(txtFirstName)
arrTXT.Add(txtLastName)
'etc

Class.Method(arrTXT)

 

Which would be faster, (Arrayslists seem to be much more flexible)and in the Class Method does it make a difference speed wize using ByRef in the method signature vs ByVal (I thought arrays always were passed by reference)

 

Thanks (:

  • *Experts*
Posted

It all depends on what you're going to be using it for. ArrayLists can

be used like collections, where you can add, remove and insert

objects of any kind. Arrays are generally best if the data is going to

be accessed by index, because the index of an item in an array won't

change; ArrayList items can be removed, which will renumber all of

the items in the ArrayList.

 

You don't use one instead of the other, as they both have their places.

ArrayLists are good for storing a collection of objects, arrays are good

when you need to have an index->data relationship (just one example).

Posted

Thanks for the info..

 

I use arrays a lot to pass to methods, however i am faced with a situation where if i had a flexible array, or dynamic ..then i could build a very poweful small routine to fill any amount of text boxs i send it. I can make an array work, but i would have to use a select case statement and dim the array within each to corrospond to the amount of textboxes i am sending it.

 

I could use a single declration of an arraylist however and avoid that...however I would have to code adding and removing items.

 

there are ups and downs to both i guess. What I am wondering most though is which has better performance...(and my question regarding ByRef)

 

Thanks.

 

 

;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...