This is a kindergarten tutorial on how to add a dataset as a hashtable entry item and how to
retrieve the values from the hashtable.
I was looking out for a class in .NET that resembled the propertyBag. What a relief when
I found this class on msdn.
Hashtable is a class in
System.Collections. It is a collection of key-and-value
pairs that are organized based on the hash code of the key.
The file in the source code contains a function
to set a dataset into a hashtable and return it to
the calling function. First we create a new hashtable, like so
Dim htbl As System.Collections.Hashtable = New System.Collections.Hashtable()
The dataset is populated using a
Dim ds As DataSet = New DataSet()
Next we add the populated dataset onto the hashtable and return it. The syntax for the add
is as follows
Public Overridable Sub Add(ByVal key As Object, ByVal value As Object) _
is the element to add, and the
is the value of the key to add.
So we add the dataset into the
and return the hashtable to the calling function.
Now getting on to the calling function. We call
which will return a
. We now try to get the dataset back from the
stores the key-value
pairs based on the hash code of the key. This way, we can access the key value by doing a lookup of
ds = htbl("CustomerDetails")
Now you got the dataset from the hashtable.
That was a very basic code!
The purpose of the article was to explain the concept behind adding in and retrieving objects from
the hashtable. However the real purpose of using the hashtable goes much beyond this. This article
is just to get u started up on