472,145 Members | 1,490 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Difference between a collection and arraylist?

I'm new to the vb.net scene, (from vb6) and would appreciate if someone
could explain the difference between the two? From all I've read they
seem to be the exact same thing?

And as an expansion of that question, if i declare a public arraylist,
how do i view its items from any procedure I happen to be in
(app-wide), in the locals window?

thanks

Nov 29 '06 #1
3 10413

"AppleBag" <ap******@gmail.comwrote in message
news:11**********************@80g2000cwy.googlegro ups.com...
I'm new to the vb.net scene, (from vb6) and would appreciate if someone
could explain the difference between the two? From all I've read they
seem to be the exact same thing?

And as an expansion of that question, if i declare a public arraylist,
how do i view its items from any procedure I happen to be in
(app-wide), in the locals window?

thanks
An ArrayList is a specific type of collection. This article may help clarify
the relationship.

http://msdn2.microsoft.com/en-gb/library/0ytkdh4s.aspx
Nov 29 '06 #2
AppleBag,

The VB6 Collection class stores key-value pairs and can be searched by
key or index where the index represents the position in the data
structure where the item is stored. If an index is not specified
during insertion then the item is added at the end.

The ArrayList only stores values. You can search by index similar to
the way all array data structures work, but you cannot search it by key
because a key is not stored.

If you reference Microsoft.VisualBasic.dll you'll be able to use a VB6
like Collection. There's really no equivalent data structure in the
System.* namespace hierarchy. The VB6 Collection is more or less an
amalgamation of ArrayList and Hashtable found in the System.Collections
namespace.

Brian

AppleBag wrote:
I'm new to the vb.net scene, (from vb6) and would appreciate if someone
could explain the difference between the two? From all I've read they
seem to be the exact same thing?

And as an expansion of that question, if i declare a public arraylist,
how do i view its items from any procedure I happen to be in
(app-wide), in the locals window?

thanks
Nov 29 '06 #3
Thank you both very much for the explanations.

Also, regarding my OP, how can I view the items in the arraylist from
anywhere, if i declare the AL as Public on one of my forms?

Brian Gideon wrote:
AppleBag,

The VB6 Collection class stores key-value pairs and can be searched by
key or index where the index represents the position in the data
structure where the item is stored. If an index is not specified
during insertion then the item is added at the end.

The ArrayList only stores values. You can search by index similar to
the way all array data structures work, but you cannot search it by key
because a key is not stored.

If you reference Microsoft.VisualBasic.dll you'll be able to use a VB6
like Collection. There's really no equivalent data structure in the
System.* namespace hierarchy. The VB6 Collection is more or less an
amalgamation of ArrayList and Hashtable found in the System.Collections
namespace.

Brian

AppleBag wrote:
I'm new to the vb.net scene, (from vb6) and would appreciate if someone
could explain the difference between the two? From all I've read they
seem to be the exact same thing?

And as an expansion of that question, if i declare a public arraylist,
how do i view its items from any procedure I happen to be in
(app-wide), in the locals window?

thanks
Nov 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by MrNobody | last post: by
7 posts views Thread by juli | last post: by
5 posts views Thread by Keith O | last post: by
13 posts views Thread by Murat Ozgur | last post: by
reply views Thread by Saiars | 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.