将写内容过程经常用的内容片段备份一下,如下的资料是关于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;
}
}
}
网友评论