我想从列表中删除一个项目,我搜索过,我尝试了所有版本的Remove(Remove,RemoveAt,RemoveAll)方法,但我无法弄明白。该项目始终存在。我的代码:
foreach (Question q in questions)
{
foreach (QuestionValue qv in q.QuestionValueList)
{
if (m_User.OrganizationRole.QuestionValuePermissionList.Where(p => p.QuestionValue.QuestionValue_Id == qv.QuestionValue_Id).Count() == 0)
{
int i = questions.FindIndex(p => p.Question_Id == q.Question_Id);
QuestionValue item = questions[i].QuestionValueList.Find(p => p.QuestionValue_Id == qv.QuestionValue_Id);
questions[i].QuestionValueList.Remove(item);
}
}
}