user3916429 user3916429 - 1 year ago 104
C# Question

Get all Keys from a MultiDictionary

Im looking for a way to get all FIRST level Keys of a multiDictionary and im totaly unable to get them (its for debugging purpose)

i declared the dictionary like this :

private Dictionary<string, Dictionary<string, Packet>> PacketsStore = new Dictionary<string, Dictionary<string, Packet>>();

So how can i print out a list of all the base keys?

how could i then print out the second level keys incase i need it too later...

thanks in advance!

Answer Source
foreach(KeyValuePair<string, Dictionary<string, Packet>> entry in PacketsStore)
    string key = entry.Key; // first level
    foreach(KeyValuePair<string, Packet> entryInner in entry.Value)
       string keyInner = entryInner.Key // second level

I have taken keys into variables you can take the same into some collection. Purpose was to get keys :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download