[英]Can't remove item from aux.Value on list of dictionary
大家好,我無法從新的List<Criar_Requisitos>
刪除ISBN的位置ISBN。 我在書單上有ISBN
,並保存在新的List<Criar_Requisitos>
,我使用foreach
和if
s。 我在foreach
的第二項上仍然出錯,你們可以幫忙嗎?
foreach (KeyValuePair<int, List<Criar_Requisitos>> aux in Nova_Lista)
{
foreach (Criar_Requisitos posição in aux.Value)
{
if (Introduzir_ISBN == posição.ISBN)
{
aux.Value.Remove(posição);
}
}
}
您可以嘗試RemoveAll而不是inner foreach
:
foreach (KeyValuePair<int, List<Criar_Requisitos>> aux in Nova_Lista)
aux.Value.RemoveAll(posição => posição.ISBN == Introduzir_ISBN);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.