Collection classes question

  • Thread starter Thread starter Will
  • Start date Start date
W

Will

I have a set of parameter names and values (essentially key/value pairs)
that I'm reading from a DB. I need to temporarily store these pairs so that
I can later format them an write them to a file. I will not need to look up
values in the collection - just reading them in and sptting them back out
sequentially. This leads me to believe that a HashTable isn't what I need.
Hmm...just found an exaply using a Dictionary and an Enumerator to traverse
it. Is this the best solution?

Thanks in advance,
Will.
 
There is probably some unnecessary overhead there. If you know how many
items you'll have, just create a two-dimensional array. If it varies, create
an ArrayList.

$0.02
 
Hi Will,
Why Hastable doesn't work for you? There is no Dictionary class. Hastable is
the dictionary.
There is DictionaryBase class as well, which is meant to be used for making
strongly-typed hashtables.
If you want to traverse all data in the hashtable you can use Values
property. if you want to traverse and read all key/value pairs you can do

foreach(DictionaryEntry de in hastable)
{
//de.Key is the key;
//de.Value is the value;
}

HTH
B\rgds
100
 
Thanks guys...I decided on an ArrayList of DictionaryEntry's, which works
fine and seems logical to me.

Will.
 
Back
Top