String indexed collection

I'm looking for a tutorial in VB.NET (instead of VB6) on something similar to the project in this link "A Fast Index-Based Collection"
I'm intersted in building a collection with a string index that I can use to store values in it's objects.  Thanks.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi there,

I think you should be able to use a hashtable to achieve what you want.

Look it up in the MSDN.

Hope to help.

Mike TomlinsonMiddle School Assistant TeacherCommented:
You can't access a HashTable by Index though.  It is possible to access the Keys/Values collections by Index, but they are sorted based on the hash value of the Key...not the insertion order.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ChaffeAuthor Commented:
just to give you a little idea on what I'm tyring to do, I get  a query string in my URL of my web application (?pageid=1) and I use that id do everything in my application.  I got to a point where I have a select case in every function that checks for the PageId.
my goal is to try and get away from all these select cases by creating some sort of collection that I can reference by pageid (similar to a primary key in a sql table) and be able to store some values (such as function names, lables, etc...) by this index.
I considered having a SQL table to store all this and query it on every request, but if I can accomplish the same thing without a trip to the DB, it'll be better.  Any thoughts?
Mike TomlinsonMiddle School Assistant TeacherCommented:
Then I think doobdave was correct after all in his suggestion of a HashTable.

Create a Class to hold the info you want and store that in the HashTable using the pageid as the Key.

Here is a simple example...

    Public Class Dog
        Public Name As String
        Public Breed As String
        Public Naughty As Boolean
    End Class

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ht As New Hashtable

        Dim d As New Dog
        d.Name = "Fido"
        d.Breed = "Wire Haired Fox Terrier"
        d.Naughty = True
        ht.Add("dog1", d)

        d = New Dog
        d.Name = "Lassie"
        d.Breed = "Labrador"
        d.Naughty = False
        ht.Add("dog2", d)

        d = ht.Item("dog1")
        MsgBox(d.Name & ", " & d.Breed & ", " & d.Naughty)

        d = ht.Item("dog2")
        MsgBox(d.Name & ", " & d.Breed & ", " & d.Naughty)
    End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChaffeAuthor Commented:
Idle_Mind & doobdave,
Thanks.  I think this is what I'm looking for.  Since I already know what everthing is going to be based on my id, I will be "hardcoding" these properties (.breed, .name, etc...)
Do you think I should have these properties in a structure and have a function inside that structure (similar to the Button1_Click in your example) that would do all the assignments.  And just call this function on every request.  Or is there a better way.
Mike TomlinsonMiddle School Assistant TeacherCommented:
I don't do web based development unfortunately so I don't know the ins and outs of variable scope/lifetime across page requests etc...

Perhaps doobdave has some input on that aspect?..
ChaffeAuthor Commented:
Thanks Idle_Mind  for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.