无聊一下,感觉有点用记录一下,^_^ 用过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全部内容,希望文章能够帮你解决C# Linq所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)