本文实例讲述了C#使用linq查询大数据集的方法。分享给大家供大家参考。具体如下:
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#程序设计有所帮助。
新闻热点
疑难解答