Linq to 泛型集合查询集合包括大写M和年龄小于等于18
#region Linq to 泛型集合查询集合包括大写M和年龄小于等于18
//List<Student> list = new List<Student>();
//list.Add(new Student { Name = "Tom", Age = 17 });
//list.Add(new Student { Name = "Jerry", Age = 16 });
//list.Add(new Student { Name = "Marry", Age = 18 });
//list.Add(new Student { Name = "Monika", Age = 22 });
//list.Add(new Student { Name = "Frank", Age = 20 });
//list.Add(new Student { Name = "Alex", Age = 15 });
////在讲解中,可以演示除了Contains之外的其他常用方法
//var result = from s in list
// where s.Name.Contains("M") && s.Age >= 18
// select s;
//foreach (var stu in result)
//{
// Console.WriteLine("姓名:{0},年龄:{1}", stu.Name, stu.Age.ToString());
//}
#endregion
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步