如何更新字典和LT所有的值;字符串,布尔> [英] How to update all the values in a Dictionary<string, bool>

查看:157
本文介绍了如何更新字典和LT所有的值;字符串,布尔>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C#VS2005紧凑框架。



我需要更新字典中的假所有的值。

 的foreach(在parameterDictionary.Keys.ToList字符串键())
parameterDictionary [关键] = FALSE;



了ToList()不可用在compactframework。
我怎样才能循环和更新。



任何一个可以建议更新在字典中的所有值的方式。


< DIV CLASS =h2_lin>解决方案

我不知道是否该紧凑架构是不同的,但你不能修改字典KeyValuePair直接在foreach。你必须先复制键列表:

 列表<串GT;键=新的List<串GT;(parameterDictionary.Keys); 
的foreach(在钥匙串键)
parameterDictionary [关键] = FALSE;


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.

解决方案

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;  

这篇关于如何更新字典和LT所有的值;字符串,布尔&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆