void test(int cur, int cnt)
{
List<string> list = new List<string>(m_pptData.dicPpt.Keys);
foreach (string key in list)
{
if (int.Parse(key) > cur)
{
int newId = int.Parse(key) + cnt;
m_pptData.dicPpt.Add(newId.ToString(), m_pptData.dicPpt[key]);
m_pptData.dicPpt.Remove(key);
}
}
}
1.把key 存到一个list中
2.遍历list,如果符合条件就新存入字典中,然后删除字典旧项
本文介绍了一个使用C#进行字典操作的例子,包括如何将符合条件的键值对迁移至新的键,并从原始字典中移除旧的键值对。通过具体的代码片段展示了整个过程。
1302

被折叠的 条评论
为什么被折叠?



