110,538
社区成员
发帖
与我相关
我的任务
分享
Dictionary<int, int> abc = new Dictionary<int, int>();
方法外全局变量 Count=0;
abc.Add(1, 1);
abc.Add(2, 2);
abc.Add(3, 1);
abc.Add(4, 3);
abc.Add(5, 1);
abc.Add(6, 4);
var q = abc.GroupBy(x => x.Value).Where(x=>x.Count()>1).Select(x => new { Key=x.Key, Count=x.Count() }).ToList();
Count=q-Count;
for(int i=0;i<Count;i++){Console.WriteLine(q[i].Key+"---"+q[i].Count);Count-i;}
List<xxx> list;
int i=0;//这两个是全局变量
你执行linq的那段代码方法()
{
list= valueDup.ToList();
i=0;
}
点击事件()
{
if(list.Count-1>i)
{
var item = list[i];
MessageBox.Show("重复的key是:" + item.Key.ToString());
i++;
}
}