| C#IList取前N行使用Take<T>()方法 
 大家如果想取List中的前N行就可以使用Take<T>()方法
 
 
 如下
 
 [C#] 纯文本查看 复制代码 IList<int> IDs = new List<int>();
                    IDs = IDs .Take(10).ToList<int>();还可以使用条件查询
 
 如下签名
 
 [C#] 纯文本查看 复制代码   //
        // 摘要:
        //     从序列的开头返回指定数量的连续元素。
        //
        // 参数:
        //   source:
        //     要从其返回元素的序列。
        //
        //   count:
        //     要返回的元素数量。
        //
        // 类型参数:
        //   TSource:
        //     source 中的元素的类型。
        //
        // 返回结果:
        //     一个 System.Collections.Generic.IEnumerable<T>,包含输入序列开头的指定数量的元素。
        //
        // 异常:
        //   System.ArgumentNullException:
        //     source 为 null。
        public static IEnumerable<TSource> Take<TSource>(this IEnumerable<TSource> source, int count);
        //
        // 摘要:
        //     只要满足指定的条件,就会返回序列的元素。
        //
        // 参数:
        //   source:
        //     要从其返回元素的序列。
        //
        //   predicate:
        //     用于测试每个元素是否满足条件的函数。
        //
        // 类型参数:
        //   TSource:
        //     source 中的元素的类型。
        //
        // 返回结果:
        //     一个 System.Collections.Generic.IEnumerable<T>,包含输入序列中出现在测试不再能够通过的元素之前的元素。
        //
        // 异常:
        //   System.ArgumentNullException:
        //     source 或 predicate 为 null。
        public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, bool> predicate);
        //
        // 摘要:
        //     只要满足指定的条件,就会返回序列的元素。将在谓词函数的逻辑中使用元素的索引。
        //
        // 参数:
        //   source:
        //     要从其返回元素的序列。
        //
        //   predicate:
        //     用于测试每个源元素是否满足条件的函数;该函数的第二个参数表示源元素的索引。
        //
        // 类型参数:
        //   TSource:
        //     source 中的元素的类型。
        //
        // 返回结果:
        //     一个 System.Collections.Generic.IEnumerable<T>,包含输入序列中出现在测试不再能够通过的元素之前的元素。
        //
        // 异常:
        //   System.ArgumentNullException:
        //     source 或 predicate 为 null。
        public static IEnumerable<TSource> TakeWhile<TSource>(this IEnumerable<TSource> source, Func<TSource, int, bool> predicate);
 |