using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, string> data = new Dictionary<string, string>();
data.Add("aa", "11");
data.Add("bb", "22");
string[] keys = new string[data.Keys.Count];
data.Keys.CopyTo(keys, 0);
foreach (var key in keys)
{
data[key] = "55";
}
foreach (var key in data.Keys)//里面的操作都会报错,无法操作,所以采用上面先保存KEYS,然后再处理的方式。
{
//data.Add("cc", "33");
//data[key] = "33";
//data.Remove("aa");
}
Console.ReadKey();
}
}
}