Collection verses List of

Posted on 2011-10-12
Last Modified: 2012-05-12
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.  
Question by:HLRosenberger
    LVL 1

    Accepted Solution

    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"))
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Do you need to preserve the order of the items too?...
    LVL 1

    Author Comment

    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.
    LVL 85

    Assisted Solution

    by:Mike Tomlinson
    apuma has given you a great answer then...Dictionary is the way to go.
    LVL 1

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now