public class People
{
public string Name;
public string Age;
}
class Program()
{
static void Main(string[] args)
{
People people = new People();
people.Sex = "男";
people.Name = "Martin";
List<People> list = new List<People>();
list.Add(people);
Open<People> open = new Open<People>();
open.Display(list);
}
}
public class Open<T>
{
public void Display(List<T> list)
{
//通过传入进来的List<T> list进行linq或者lambda筛选
//求大神来解决 泛型List<T>不是已知的集合
}
}
------解决思路----------------------
public class Open<T>
{
public void Display(List<T> list, Func<T, bool> filter)
{
foreach (T value in list)
{
if (filter(value))
{
//通过传入进来的List<T> list进行linq或者lambda筛选
//求大神来解决 泛型List<T>不是已知的集合
}
}
}
}
open.Display(list, value => value.Sex == "男");