Collection classes question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Will

    Collection classes question

    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.
  • Jeff Molby

    #2
    Re: Collection classes question

    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

    "Will" <dev@rusmo.co m> wrote in message
    news:1o6dnZb0q4 GahCCiRVn-vw@giganews.com ...[color=blue]
    > 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[/color]
    that[color=blue]
    > I can later format them an write them to a file. I will not need to look[/color]
    up[color=blue]
    > 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[/color]
    need.[color=blue]
    > Hmm...just found an exaply using a Dictionary and an Enumerator to[/color]
    traverse[color=blue]
    > it. Is this the best solution?
    >
    > Thanks in advance,
    > Will.[/color]


    Comment

    • 100

      #3
      Re: Collection classes question

      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(Diction aryEntry de in hastable)
      {
      //de.Key is the key;
      //de.Value is the value;
      }

      HTH
      B\rgds
      100

      "Will" <dev@rusmo.co m> wrote in message
      news:1o6dnZb0q4 GahCCiRVn-vw@giganews.com ...[color=blue]
      > 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[/color]
      that[color=blue]
      > I can later format them an write them to a file. I will not need to look[/color]
      up[color=blue]
      > 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[/color]
      need.[color=blue]
      > Hmm...just found an exaply using a Dictionary and an Enumerator to[/color]
      traverse[color=blue]
      > it. Is this the best solution?
      >
      > Thanks in advance,
      > Will.[/color]


      Comment

      • Will

        #4
        Re: Collection classes question

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

        Will.

        Comment

        Working...