"Paulers" <Su*******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
I am in need of a way to store multiple elements which can be
retrieved with a unique key (string). For example, I would like to
store characteristics like first name, last name, age, and phone number
and associate them with the unique key like a USERID. Then loop
through the data collection and pull certain elements out for
processing. Which collection type would be best suited for this purpose?
/Any/ of them really, because what you'll be placing into the "collection"
is a class of your own devising that contains all these properties.
HashTable is probably the easiest, though.
Public Class Person
Public Sub New( Username as String, ...
Public ReadOnly Property Age() as Integer
Public Property DoB() as DateTime
Public Property Forename() as String
Public Property Phone() as String
Public Property Surname() as String
Public ReadOnly Property Username() as String
End Class
Dim htPeople as New HashTable
htPeople.Add( "fred", New Person( "fred", ... ) )
Dim employee as Person _
= DirectCast( htPeople.Item( "fred" ), Person )
Bear in mind, though, that some collections hold things internally
as DictionaryEntry objects, so you might have to do an extra layer
of "translation" when iterating through the items therein.
HTH,
Phill W.