遍历集合操作
for (int i = recivers.Keys.Count; i-- > 0; )
{
if (!recivers.Values.ElementAt(i).bExist)
{
recivers.Remove(recivers.Keys.ElementAt(i));
}
}
//foreach (UserDictType item in userdict.Values)
//{
// if (time > item.LogoutDatetime1)
// {
// userdict.Remove(item.UserGUID1);
// }
//}此代码当移除一个数据时可能会引起迭代器数据序列混乱
for (int i = userdict.Keys.Count; i-- > 0; )
{
if (time > userdict.Values.ElementAt(i).LogoutDatetime1)
{
userdict.Remove(userdict.Keys.ElementAt(i));
}
}