正確的寫法:
foreach(var item in waitKickDic.ToList())
{
if (item.Value.RoomDic.Keys.Contains(item.Key.user_str_id))
{
waitKickDic.Remove(item.Key);
}
}
錯誤的寫法:
foreach( KeyValuePair<string, YourClass > crrPair in ht
{
if ( crrPair.Value.ID == 1 )
ht.remove( crrPair.Key );
}