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. hashtable or Dictionary!

hashtable or Dictionary!

Scheduled Pinned Locked Moved C#
csharpquestion
11 Posts 5 Posters 1 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.
  • J Offline
    J Offline
    Jassim Rahma
    wrote on last edited by
    #1

    If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?! Thanks....

    L P D 4 Replies Last reply
    0
    • J Jassim Rahma

      If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?! Thanks....

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I am not sure why you would use a hashtable or dictionary. There is the Settings.Settings for just that purpose. Unless I am not understanding your question.

      ASCII stupid question, get a stupid ANSI

      J 1 Reply Last reply
      0
      • J Jassim Rahma

        If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?! Thanks....

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3
        1. Dictionary uses a hashtable. 1) Are your settings all one datatype?
        A J 2 Replies Last reply
        0
        • J Jassim Rahma

          If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?! Thanks....

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          If you want to save user settings, you can use Settings or create custom tags in the configuration file. Then you can read them from the configuration file when the application is loaded.

          J 1 Reply Last reply
          0
          • P PIEBALDconsult
            1. Dictionary uses a hashtable. 1) Are your settings all one datatype?
            A Offline
            A Offline
            Anindya Chatterjee
            wrote on last edited by
            #5

            One thing to remind, if you try to save settings in either of the data structures as a xml file then you are out of luck, by default both of them are not serializable. You have to implement the IXmlSerializable interface in a custom object and wrap it around the hash table.

            Regards, Anindya Chatterjee[^]

            P 1 Reply Last reply
            0
            • A Anindya Chatterjee

              One thing to remind, if you try to save settings in either of the data structures as a xml file then you are out of luck, by default both of them are not serializable. You have to implement the IXmlSerializable interface in a custom object and wrap it around the hash table.

              Regards, Anindya Chatterjee[^]

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              So what?

              1 Reply Last reply
              0
              • L Lost User

                I am not sure why you would use a hashtable or dictionary. There is the Settings.Settings for just that purpose. Unless I am not understanding your question.

                ASCII stupid question, get a stupid ANSI

                J Offline
                J Offline
                Jassim Rahma
                wrote on last edited by
                #7

                I forgot to say al the parameters are saved in SQL server and it will be populated into hashtable, dictionary or whatever your recommendation is so that I don't need to connect to the database every timeto read a single value.

                L 1 Reply Last reply
                0
                • P PIEBALDconsult
                  1. Dictionary uses a hashtable. 1) Are your settings all one datatype?
                  J Offline
                  J Offline
                  Jassim Rahma
                  wrote on last edited by
                  #8

                  not all one type but in worst case I can save all as string and convert within the application

                  1 Reply Last reply
                  0
                  • D dan sh

                    If you want to save user settings, you can use Settings or create custom tags in the configuration file. Then you can read them from the configuration file when the application is loaded.

                    J Offline
                    J Offline
                    Jassim Rahma
                    wrote on last edited by
                    #9

                    do you have an example of doing this (hashtable or dictionary) in a public class and use it across the application?

                    1 Reply Last reply
                    0
                    • J Jassim Rahma

                      I forgot to say al the parameters are saved in SQL server and it will be populated into hashtable, dictionary or whatever your recommendation is so that I don't need to connect to the database every timeto read a single value.

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      It is a simple question of object type then. If your key is consistent (e.g. UserID as a string, or a custom UserID object) as well as your containing values you should deffinately use a dictionary for performence and your own sanity. If these objects vary then you are stuck with the hash table. A Dictionary is a hashtable with generics, i.e. no casting is necessary which is a performance gain and will avoid incorrect casting that can cause run time errors.

                      ASCII stupid question, get a stupid ANSI

                      1 Reply Last reply
                      0
                      • J Jassim Rahma

                        If I want to save the user setting and permissions and my system parameters for the application public use (in C#)... what's the best way to do it? hashtable or dictionary? or maybe another way?! Thanks....

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #11

                        Ah, so you're still asking about these: http://www.codeproject.com/Messages/3432325/create-public-variables-at-run-time.aspx[^] http://www.codeproject.com/Forums/1649/Csharp.aspx?fid=1649&tid=3429896[^]

                        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