CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2013
    Posts
    2

    Generic Dictionary consisting of string & linkedlist

    Hey,

    So, I have a generic dictionary (key = name, value = linkedlist).
    public Dictionary<string, LinkedList<string>> myDictionary = new Dictionary<string, LinkedList<string>>();

    I know how to insert values into the linkedlist (the value part of the dictionary), however, I do not know how to retrieve/display them. I have managed to retrieve the first, and last entries within the linkedlist through this:
    entry.Value.First.Value entry.Value.Last.Value
    ^the above code is placed within a foreach loop of the dictionary.

    I want to input an unspecific amount of entries into the linkedlist, and be able to put them all into 1 string, or display them.

    How can I do this? Is it possible? I have been stuck for far too long now, please help

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Generic Dictionary consisting of string & linkedlist

    Code:
    // access the linked list for a single dictionary key and enumerate the list items
    foreach(var stringEntry in myDictionary["keyValue"]) 
    {
    
    }
    
    // access the linked list for all the keys
    foreach(var linkedListEntry in myDictionary.Values) 
    {
      foreach(var stringEntry in linkedListEntry) // enumerate the list items
      {
    
      }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured