Straight from the w3schools web site,
why would I want to put these items into a hashtable?
Is this more for large amounts of data and this is just a simple demo?
Otherwise why would I spend the time to put it into a hashtable why not just put it in an array?
dim mycountries=New Hashtable
mycountries.Add("N","Norway")
mycountries.Add("S","Sweden")
mycountries.Add("F","France")
mycountries.Add("I","Italy")
rb.DataSource=mycountries
rb.DataValueField="Key"
rb.DataTextField="Value"
rb.DataBind()
An array holds a bunch of single-valued things.
A Hashtable (or indeed also a Dictionary) holds a bunch of key-value pairs.
When one later enumerates a Hashtable, one gets back a
KeyValuePair<string,string>rather than just astringone would get from the Collection.This example sets the key to a short version of the value, so an array would not work (it can only hold a value).
Certainly you could use an array that holds a type that in turn has a key and a value, but using a Hashtable is more straightforward.