メインリスト内のすべてのリストを繰り返し、特定の条件が発生した場合は繰り返します。私はその特定のリストを削除したい。ループ内のリストからリストを安全に削除する
動作しません。
for (int i = 0; i < mainList.Count; i++)
{
if (mainList[i].Dead == true) //
{
mainList.removeAt(i);//what will be affect on mainList.Count;
}
}
[C#でそれを反復しながら、列挙コレクションから項目を変更または削除する方法]の可能複製(HTTP ://stackoverflow.com/questions/308466/how-to-modify-or-delete-items-from-an-enumerable-collection-while-terating-throu) –