遍历并修改dictionary的值

System.Collections.Generic.Dictionary<test ,string > dic=new Dictionary<test,string> ();
            test djj = new test();
            dic.Add(djj,"wyl");
            List<test> list = new List<test>();
            list.AddRange(dic.Keys);
            list[0].name = "djj2";
            foreach (test t in list)
            {
                dic[t] = "wyl2";
            }
            Console.WriteLine(dic[list[0]]);

posted @ 2010-11-25 14:20  sweetjian  阅读(7724)  评论(0编辑  收藏  举报