在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
/*--===------------------------------------------===---
Lambda表达式 Lambda Expressions 许明会 2007年12月3日 20:11:40 --===------------------------------------------===---*/ using System; using System.Collections.Generic; //引入泛型 using System.Linq; //Lambda表达式查询必须引入Linq空间 namespace xumh { public class student { public string firstname{get;set;} public string lastname{get;set;} public string corperation{get;set;} } public class runMyApp { static void Main() { List<student> stu = new List<student> { new student{firstname="xu", lastname="minghui", corperation="jbird"}, new student{firstname="sun", lastname="weiping", corperation=""}, new student{firstname="xu", lastname="zihao", corperation="home"} }; //p => p.firstname.StartsWith("xu") //这就是Lambda表达式 var result = stu.Where(p => p.firstname.StartsWith("xu")); //var result = from p in stu where p.firstname.StartsWith("xu") select p; foreach(var v in result) Console.WriteLine("{0} {1},工作于{2}.", v.firstname, v.lastname, v.corperation); } } } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论