【发布时间】:2016-02-05 00:46:32
【问题描述】:
我有一个班级House,我创建了一个List<House> 和一些新的房子。现在我想过滤我的List' where the Name of the House equals"House 1"`。
我应该如何处理这种情况?
我试过houses.FindAll("House 1"); 但这显示了错误:
参数 1:无法从 'string' 转换为 System.Predicate
class House
{
public House(string name, string location)
{
this.Name = name;
this.Location = location;
}
public string Name { private set; get; }
public string Location { private set; get; }
};
//TODO: fill this with data from the database
List<House> houses= new List<House>
{
new House("House 1", "Location 1"),
new House("House 2", "Location 4"),
new House("House 3", "Location 3"),
new House("House 4", "Location 2")
};
【问题讨论】: