Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update all the values in a Dictionary<string, bool>

I am using c# vs2005 compact framework.

I need to update all the values in the dictionary to false.

foreach (string key in parameterDictionary.Keys.ToList())
  parameterDictionary[key] = false;

".ToList() is not available" in compactframework. How can i loop and update.

Can any one suggest the way to update all the values in a dictionary.

like image 422
user745607 Avatar asked Jul 17 '11 13:07

user745607


1 Answers

I don't know if the compact framework is different, but you can't modify the dictionary KeyValuePair directly in a ForEach. You have to copy a list of keys first:

List<string> keys = new List<string>(parameterDictionary.Keys);
foreach (string key in keys)
  parameterDictionary[key] = false;  
like image 172
LarsTech Avatar answered Sep 28 '22 10:09

LarsTech