Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. NameValueCollection or HashTable

NameValueCollection or HashTable

Scheduled Pinned Locked Moved C#
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    student_rhr
    wrote on last edited by
    #1

    Hello everyone: I need to use a collection technique but I am not sure which one will be best for my situation. I have relational data that I need to store; I have a table that has Keys and another table has values, each KEY may contain mulitple values. Both KEY and VALUE are string, can you suggest me which (NameValueCollection or HashTable) I should use? Thanks a lot.

    G N L 3 Replies Last reply
    0
    • S student_rhr

      Hello everyone: I need to use a collection technique but I am not sure which one will be best for my situation. I have relational data that I need to store; I have a table that has Keys and another table has values, each KEY may contain mulitple values. Both KEY and VALUE are string, can you suggest me which (NameValueCollection or HashTable) I should use? Thanks a lot.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      The tables that you are talking about, are they database tables? In what way can the key contain multiple values? --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • S student_rhr

        Hello everyone: I need to use a collection technique but I am not sure which one will be best for my situation. I have relational data that I need to store; I have a table that has Keys and another table has values, each KEY may contain mulitple values. Both KEY and VALUE are string, can you suggest me which (NameValueCollection or HashTable) I should use? Thanks a lot.

        N Offline
        N Offline
        NatLang
        wrote on last edited by
        #3

        I'm a newbie so take my advice with a grain of salt, but it seems like NameValueCollection was designed with exactly that in mind. The alternative would be a HashTable with arrays of strings for the values, but NameValueCollection takes care of some of the dirty work there -- although it does get a little messy when you only want to access one of the many values stored under a key. That will be $0.02 please. Cash or charge?

        1 Reply Last reply
        0
        • S student_rhr

          Hello everyone: I need to use a collection technique but I am not sure which one will be best for my situation. I have relational data that I need to store; I have a table that has Keys and another table has values, each KEY may contain mulitple values. Both KEY and VALUE are string, can you suggest me which (NameValueCollection or HashTable) I should use? Thanks a lot.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          They are both the same. For the value bit you simple need to use another Hashtable or ArrayList. Seems tricky at 1st due to the extra casting, but once u write a few of them its like writing a for loop :p

          xacc.ide-0.1.2.15
          Now with a grid!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups