返回顶部

收藏

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;
        }
    }
}

标签:linq,查询,大数据

收藏

0人收藏

支持

0

反对

0

发表评论