Generic Dictionary consisting of string & linkedlist

j0rd4nn

New member
Joined
Dec 18, 2013
Messages
4
Programming Experience
5-10
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 :)
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,137
Location
Sydney, Australia
Programming Experience
10+
Why are you using a LinkedList in the first place? If you don't know how to traverse a LinkedList then it suggests that you probably don't have a requirement to use one and should probably just be using a List or the like.
 
Top Bottom