小用lambda表達式,查詢數組裏大於80的個數

 

本身對lambda沒有涉及,這個小技巧簡單記錄下,方便以後用。

int[] scores = { 90, 71, 82, 93, 75, 82 };

// The call to Count forces iteration of the source
int highScoreCount = scores.Where(n => n > 80).Count();

int asad = highScoreCount;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章