[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Collection verses List of

Is there a way to use a collection but have it be aware of the type of objects that it contains, like with List Of?

I want the ability to reference a member of the collection using a key, but being able to know the types would be nice too.  
0
HLRosenberger
Asked:
HLRosenberger
  • 2
  • 2
2 Solutions
 
apumaCommented:
you could look at using the dictionary objects

Dim x As New Generic.Dictionary(Of String, Student)

x.Add("Billy Johnson", New Student("Billy Johnson", _
"123 Main St.", "Anywhere, FL 12345"))

http://adventuresdotnet.blogspot.com/2007/10/vbnet-generic-dictionaries.html
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Do you need to preserve the order of the items too?...
0
 
HLRosenbergerAuthor Commented:
I do not need to preserve the order.  Just need to access each item via a key which was used when entering into the list or collection.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
apuma has given you a great answer then...Dictionary is the way to go.
0
 
HLRosenbergerAuthor Commented:
Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now