您的位置:首页 > 其它

Linq查询非泛型集合要指定Student类型(比如List)

2015-03-25 19:31 411 查看
#region Linq to 集合查询非泛型集合要指定Student类型
//ArrayList list = new ArrayList();
//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 });
////要指定Student类型
//var result = from Student s in list
// where s.Name.Contains("M") && s.Age >= 18
// select s;

//foreach (Student stu in result)
//{
// Console.WriteLine("学员姓名:{0},年龄:{1}", stu.Name, stu.Age.ToString());
//}
#endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐