zoukankan      html  css  js  c++  java
  • LINQ 学习笔记8 Kevin

    Chapter 4 延迟操作


    1.引用命名空间

    using System.Linq;

    using System.Collections;

    using System.Collections.Generic;

    using System.Data.Linq;

    2.Where方法

    WHere 方法的作用是根据查询条件过滤结果。

    where 方法有两个原型:

    第一个:

    public static IEnumerable<T> Where<T>(

    this IEnumerable<T> source,

    Func<T,bool> predicate);

     该原型的作用是通过输入一个可以进行Enumberable的序列,返回那些满足委托条件返回true的元素。

    第二个:

    Public static IEnumberalbe<T> source,Func<T,int,bool> predicate);

    第二个原型与第一个原型是一样的,除了它接比第一个多接受一个int类型的参数。这个是参数是输入参数中的Index。

    Index是以0为开始的,所以的第一个参数的Index是0,最后一个参数的Index是参数个数减1.

    Exception:

    如果参数中有参数为null,将会抛出一个ArgumentNullException异常。

    Select


    select 操作符用来创建一种类型的结果集,并非一定要和输入的元素类型相同。

    第一种原型:

    Public static IEnumberable<S> Select<T,S>(

      this IEnumberable<T> source,

         Func<T,S> selector

    );

  • 相关阅读:
    深入Python(一)
    深入Python(二)
    初识Python(五)
    初识Python(一)
    深入Python(三)
    一、MongoDB的下载、安装与部署
    浏览器上的javascript
    javascript中的事件
    扩展方法
    团队项目开题报告
  • 原文地址:https://www.cnblogs.com/kfx2007/p/2706394.html
Copyright © 2011-2022 走看看