lambda表达式嵌套

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace ConsoleTest
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             var personList = new List<Person>()
14             {
15                 new Person() {Name="YC1",Age=22,Sex="" },
16                 new Person() {Name="YC2",Age=23,Sex="" },
17                 new Person() {Name="YC3",Age=24,Sex="" },
18                 new Person() {Name="YC4",Age=25,Sex="" },
19                 new Person() {Name="YC5",Age=26,Sex="?" },
20                 new Person() {Name="YC6",Age=27,Sex="" },
21                 new Person() {Name="YC7",Age=28,Sex="" },
22                 new Person() {Name="YC8",Age=29,Sex="" },
23                 new Person() {Name="YC9",Age=30,Sex="" },
24                 new Person() {Name="YC10",Age=31,Sex="" }
25             };
26 
27             var list = personList.Where(d => d.Age.Equals(personList.Where(e => e.Sex == "?").Max(e => e.Age))).ToList();
28 
29             foreach (var v in list)
30             {
31                 Console.WriteLine(v.Name + "--" + v.Age + "--" + v.Sex);
32             }
33 
34             Console.ReadLine();
35         }
36     }
37 }

输出了sex="?"的那一行数据

 

转载于:https://www.cnblogs.com/YCconfig/p/5798018.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值