Friday, July 31, 2009

How to work with the HashTable collection in Visual Basic .NET

From
http://support.microsoft.com/kb/307933

I keep forgetting how to test membership or how to retrieve objects from the Hashtable. It's actually too simple to be well-documented :)

You just use

Dim table as New HashSet(Of String)
table("foo") = "foo"

To retrieve, just use
table("foo")

which would return "foo".

Usually you might want to store something more complex under the key, but this is all that's needed to add to a set and test set membership - which is what I usually want.

No comments:

Post a Comment