C#(一) Linq表达式

筛选分数大于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();

Join  参考https://mp.weixin.qq.com/s/Bf_cHt7Yl1yBudbQKOhdTg

let   参考 https://mp.weixin.qq.com/s/AUwbq7gWGZa9K4W0SGhEfA

猜你喜欢

转载自blog.csdn.net/LinZhonglong/article/details/124469225