C# linq語句學習
阿新 • • 發佈:2019-04-29
where space names 語句 app static app1 for read
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(); } } }
C# linq語句學習