Program.cs 841 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleLINQOperObjects
  7. {
  8. internal class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. int[] intScores = { 45, 68, 80, 90, 75, 76, 32 };//定义int类型的一维数组
  13. //使用LINQ技术从数组中查找及格范围内的分数
  14. var score = from hgScroe in intScores
  15. where hgScroe >= 60
  16. orderby hgScroe ascending
  17. select hgScroe;
  18. Console.WriteLine("及格的分数:");
  19. foreach (var v in score)//循环访问查询结果并显示
  20. {
  21. Console.WriteLine(v.ToString());
  22. }
  23. Console.ReadLine();
  24. }
  25. }
  26. }