using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LargeNumberQuery { class Program { static void Main(string[] args) { int[] numbers = CreateNumbers(7384738); Console.WriteLine("Numbers less than 2000:"); var queryResults = from n in numbers where n < 2000 select n; foreach (var item in queryResults) { Console.WriteLine(item); } Console.ReadLine(); } private static int[] CreateNumbers(int count) { Random generator = new Random(0); int[] result = new int[count]; for (int i = 0; i < count; i++) { result[i] = generator.Next(); } return result; } } }
希望本文所述对大家的C#程序设计有所帮助。