Linq中的分区指的是在不重新排列元素的情况下,将输入序列划分为两部分,然后返回其中一个部分的操作。 一、Take操作符 Take(int n)表示将从序列的开头返回数量为n的连续元素,常用于分页。其定义如下: 1 public static IEnumerable<TSource> Take<TSource>( this IEnumerable<TSource> source, int count); 该方法只接受一个整数,表示要返回的结果的数量。 看下面的例子: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 7 namespace PartitionOperation 8 { 9 class Program 10 { 11 static void Main( string [] args) 12 { 13 int [] source = new int [] { 86 , 2 , 77 , 94 , 100 , 65 , 5 , 22 , 70 , 55 , 81 , 66 , 45 }; 14 // 返回6个连续的数据 15 var q = source.Take( 6