修改.NET词典而通过它枚举 [英] Modifying .NET Dictionary while Enumerating through it

查看:120
本文介绍了修改.NET词典而通过它枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我真的字典,我想,而我通过它枚举去改变它,但似乎这是不允许的。 我怎样才能做到这一点?

I`m using a Dictionary and I want to change it while I Enumerate through it, but it seems this is not allowed. How can I do this?

感谢

推荐答案

您应该存储密钥,或者您想删除打破循环,然后使用删除方法从字典中删除的对象的对象。

You should store the key or object you want to delete and break the loop, and then use remove method to delete the object from dictionary.

希望这有助于

这篇关于修改.NET词典而通过它枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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