首页 > Windows开发 > 详细

C# Linq

时间:2019-09-28 14:52:57      阅读:78      评论:0      收藏:0      [点我收藏+]

无聊一下,感觉有点用记录一下,^_^  用过linq的请绕道...

            List<Test> list = new List<Test>();
            list.Add(new Test { score = 10, name = "张君宝" });
            list.Add(new Test { score = 20, name = "刘惜君" });
            list.Add(new Test { score = 20, name = "刘惜君" });
            list.Add(new Test { score = 30, name = "八戒" });

            int total = (from temp in list
                             where temp.name == "刘惜君"
                             select temp.age).Count();

            int score = (from temp in list
                         where temp.name == "刘惜君"
                        select temp.score).Sum();
            this.textBox1.Text = "刘惜君:" + total + "人" + score + "score";

            MessageBox.Show(this.textBox1.Text);   
//return 刘惜君:2人40score

  

C# Linq

原文:https://www.cnblogs.com/YYkun/p/11603069.html

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