【发布时间】:2013-03-27 13:11:43
【问题描述】:
我无法从 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>();
}
【问题讨论】:
标签: c# .net linq generics ienumerable