我无法从 IEnumerable 列表中删除元素,但此列表是对 List 的引用,它是其他类的私有属性。如果我放入personsCollection.Remove(theElement)
同一个类(类Manager),它会完美运行,但我需要删除另一个类(类ManagerDelete)以来的元素。请问我该怎么做?谢谢。
class Other
{
//Some code
public IEnumerable<Person> SearchByPhone (string value)
{
return from person in personCollection
where person.SPhone == value
select person;
}
}
class ManagerDelete
{
//Some code
IEnumerable<Person> auxList= SearchByPhone (value);
//I have a method for delete here
}
class Manager
{
//Some code
private List<Person> personsCollection = new List<Person>();
}