C# List<T> Lambda取某一属性组合为新List(Select),并去重(Distinct)

People p1 = new People() { Age = 10, Name = "张三", Birth = Convert.ToDateTime("1966-10-1") };
People p2 = new People() { Age = 18, Name = "李四", Birth = Convert.ToDateTime("1977-10-2") };
People p3 = new People() { Age = 12, Name = "王二", Birth = Convert.ToDateTime("1988-10-3") };
List list = new List();
list.Add(p1);
list.Add(p2);
list.Add(p3);

List lstType = list1.Select(t => t.Name).Distinct().toList();
 

你可能感兴趣的:(C#,大数据)