筛选分数大于80,并且升序排列
List<int> scores = new List<int> { 5, 200, 0, 66, 4, 32, 700, 1 };
IEnumerable<int> highScoresQuery =
from score in scores
where score > 80
orderby score ascending
select score;
//ascending 升序排列
//descending 降序排列
或直接筛选不排序
var result = scores.Where(c => c>80).ToList();
这篇博客介绍了如何使用C#的LINQ查询来筛选列表中分数大于80的元素,并进行升序排序。示例代码展示了从一个整数列表中选取分数大于80的项,然后按照升序排列的过程。这涉及到LINQ的where子句用于条件筛选,以及orderby子句进行排序。无论是直接筛选还是先筛选后排序,都是对数据集合的有效操作。
4136

被折叠的 条评论
为什么被折叠?



