Answer by Julien.Lynge
One of the restrictions of a foreach loop is that you can't change the underlying thing you're iterating over. If you change a dictionary while you're iterating through it, the program has no idea if...
View ArticleAnswer by furic
Added to @Julien's answer, instead of using: foreach (string s in dict.Keys) { dict [s] = ... Use: List keys = new List (dict.Keys); foreach (string key in keys) { dict [key] = ...
View ArticleAnswer by AndyMartin458
Before I saw @furic 's answer to create a list out of the keys, I did this. Thought someone might find it useful. Item[] items = new Item[m_dict.Count]; m_dict.Values.CopyTo(items, 0); foreach (Item...
View ArticleAnswer by Trojaner
foreach (string s in dict.Keys.ToList()) { dict [s] = ... Would be the simplest solution I guess
View ArticleAnswer by Julien-Lynge
One of the restrictions of a foreach loop is that you can't change the underlying thing you're iterating over. If you change a dictionary while you're iterating through it, the program has no idea if...
View ArticleAnswer by furic
Added to @Julien's answer, instead of using: foreach (string s in dict.Keys) { dict [s] = ... Use: List keys = new List (dict.Keys); foreach (string key in keys) { dict [key] = ...
View ArticleAnswer by AndyMartin458
Before I saw @furic 's answer to create a list out of the keys, I did this. Thought someone might find it useful. Item[] items = new Item[m_dict.Count]; m_dict.Values.CopyTo(items, 0); foreach (Item...
View ArticleAnswer by Trojaner
foreach (string s in dict.Keys.ToList()) { dict [s] = ... Would be the simplest solution I guess
View Article