首页 > 其他 > 详细

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

时间:2015-03-25 21:21:09      阅读:175      评论:0      收藏:0      [点我收藏+]

   #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

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

原文:http://www.cnblogs.com/914556495wxkj/p/4366696.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!