How To Iterate Through The Dictionary

Toolkits.HowToIterateThroughTheDictionary History

Hide minor edits - Show changes to output

Added line 9:
Added line 12:
Added lines 24-25:
Added line 30:
Added lines 1-26:
[[Toolkits.Networking | << Back to the .Networking page]]

You can iterate through entries in a shared dictionary. The following code grabs each item in the dictionary and adds it to an array list. Then, it removes each item from the dictionary.

(:source lang=csharp tabwidth=2 :) [=
ArrayList removalKeys = new ArrayList();

foreach(GroupLab.Networking.SharedDictionary.Entry i in
(this.SD["/value/?"] as IEnumerable))

// note: instead of actually removing each key here
// we add it to a list of keys to remove after
// this is necessary because when iterating over an
// enumeration you cannot modify the shared dictionary

foreach(string path in removalKeys)