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. Hash Table in C#

Hash Table in C#

Scheduled Pinned Locked Moved C#
csharpdata-structurescryptographyquestion
5 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.
  • R Offline
    R Offline
    rahultaing
    wrote on last edited by
    #1

    Is there any Hash Table in C# and if yes then how do we use it? How do we add and how do we look up in hash table?

    A R B 4 Replies Last reply
    0
    • R rahultaing

      Is there any Hash Table in C# and if yes then how do we use it? How do we add and how do we look up in hash table?

      A Offline
      A Offline
      alexey N
      wrote on last edited by
      #2

      Yes, class Hashtable Hashtable hash = new HashTable(); // Adding value. hash["key"] = 0; // Getting value. MessageBox.Show(hash["key"].ToString()); You can also access data through properties "Keys" and "Values". Best regards, Alexey.

      1 Reply Last reply
      0
      • R rahultaing

        Is there any Hash Table in C# and if yes then how do we use it? How do we add and how do we look up in hash table?

        R Offline
        R Offline
        RedhaDev
        wrote on last edited by
        #3

        Hi, yes of course, by using the "Hashtable" class. Hashtable myHashTable = new Hashtable(); to instantiate a Hashtable object. myHashTable.Add("theKey", "theValue"); to add an element myHashTable["theKey"]...; to retrieve a "value" usig its "key" myHashTable.Keys; to retrieve the Keys Collection property and myHashTable.Values; to retrieve the Values Collection property Regards. -- modified at 5:03 Friday 14th April, 2006

        1 Reply Last reply
        0
        • R rahultaing

          Is there any Hash Table in C# and if yes then how do we use it? How do we add and how do we look up in hash table?

          B Offline
          B Offline
          Bob_Sun
          wrote on last edited by
          #4

          By the way, you can look up the hashtable by Hashtable.Contains() Hashtable.ContainsKey() Hashtable.ContainsValue as well.

          1 Reply Last reply
          0
          • R rahultaing

            Is there any Hash Table in C# and if yes then how do we use it? How do we add and how do we look up in hash table?

            A Offline
            A Offline
            alexey N
            wrote on last edited by
            #5

            Read this: Hashtable class Best regards, Alexey.

            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