using System; using System.Linq; namespace ConsoleApp1 { class Program { static void Main(string[] args) { int[] arr = { 1, 2, 3, 4, 5, 6 }; var a = from num in arr where num % 2 == 0 select num; foreach (var i in a) { Console.WriteLine(i); } Console.ReadKey(); var b = arr.Where(x => x % 2 == 0).OrderBy(n=>n); foreach (var i in b) { Console.WriteLine(i); } Console.ReadKey(); } } }
原文:https://www.cnblogs.com/mlh1421/p/10787225.html