110,533
社区成员
发帖
与我相关
我的任务
分享
Dictionary<int, int> abc
我要用for循环遍历。
如何引用abc中的每一项.用as或者强制装换
比如。
ArrayList(int) a
for(int i=0;i!=a.count;i++)
{
int b =(int) a[i];
}
Dictionary<int, int> abc;
List<KeyValuePair<int,int>> tempList = abc.ToList();
abc.Clear();
for (int i = 0; i < tempList.Count; i++)
{
//操作tempList
}
foreach (KeyValuePair<int, int> item in tempList)
{
abc.Add(item.Key, item.Value);
}
Dictionary<int, int> abc;
List<int> removeList = new List<int>();
foreach (KeyValuePair<int,int> item in abc)
{
if (item.Value == 1)
{
removeList.Add(item.Key);
}
}
//根据队列删除
foreach (int key in removeList)
{
abc.Remove(key);
}
foreach (KeyValuePair<int, int> kvp in abc)