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. In Key-Value Pairs , keys need not be unique , which Collection to use?

In Key-Value Pairs , keys need not be unique , which Collection to use?

Scheduled Pinned Locked Moved C#
csharpquestion
5 Posts 3 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.
  • A Offline
    A Offline
    Ash20
    wrote on last edited by
    #1

    Hi, I want to store Key-Value pairs in some data structure. In this "Keys" need not be unique , so HashTable cannot be used. The size of the collection should dynamically increased. I am not able to locate any data structure suitable to my requirement in C#. Please let me know if you have anything your side. Thanks, Ashish

    C 1 Reply Last reply
    0
    • A Ash20

      Hi, I want to store Key-Value pairs in some data structure. In this "Keys" need not be unique , so HashTable cannot be used. The size of the collection should dynamically increased. I am not able to locate any data structure suitable to my requirement in C#. Please let me know if you have anything your side. Thanks, Ashish

      C Offline
      C Offline
      C1AllenS
      wrote on last edited by
      #2

      Hello Ashish, Try using the GUID structure for the same. You may refer to the given web link for more assistance with generating GUID keys. http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335 http://www.csharphelp.com/archives/archive188.html I hope this will help. Regards, Allen

      Allen Smith ComponentOne LLC www.componentone.com

      A 1 Reply Last reply
      0
      • C C1AllenS

        Hello Ashish, Try using the GUID structure for the same. You may refer to the given web link for more assistance with generating GUID keys. http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=335 http://www.csharphelp.com/archives/archive188.html I hope this will help. Regards, Allen

        Allen Smith ComponentOne LLC www.componentone.com

        A Offline
        A Offline
        Ash20
        wrote on last edited by
        #3

        Hi Allen, Thanks for your response .I am not looking for GUID . The Key-value pair will be For Eg , Lookup 49 0 "Unclassified" 1 "Background" 2 "Desktop" 1 "LZHL" In which Key can be duplicate. I need DataStructure/Collection which can increase dynamically and can hold this values. Thanks, Ashish

        L 1 Reply Last reply
        0
        • A Ash20

          Hi Allen, Thanks for your response .I am not looking for GUID . The Key-value pair will be For Eg , Lookup 49 0 "Unclassified" 1 "Background" 2 "Desktop" 1 "LZHL" In which Key can be duplicate. I need DataStructure/Collection which can increase dynamically and can hold this values. Thanks, Ashish

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

          Dictionary<object,List<object>>

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)

          A 1 Reply Last reply
          0
          • L leppie

            Dictionary<object,List<object>>

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 alpha 4a out now (29 May 2008)

            A Offline
            A Offline
            Ash20
            wrote on last edited by
            #5

            It seems you need to have unique key in Dictionary also, Dictionary<string,> keyValue = new Dictionary<string,>(); keyValue.Add("1","\"Background\""); keyValue.Add("2", "\"AlignerFail\""); keyValue.Add("3", "\"LZHL\""); keyValue.Add("3", "\"Align\""); Unhandled Exception as already a key present. I need collection which should not contain uniqueness of key. It should accept if keys are duplicate. Can any way we can surpass the key field uniqueness in Hashtable/Dictionary collection?? Thanks, Ashish

            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