take  前几

skip   跳过前几

takeWhile

  var firstNumbersLessThan6 = numbers.TakeWhile(n => n < 6);  //从前面查询直到满足条件停止

SkipWhile

 var allButFirst3Numbers = numbers.SkipWhile(n => n % 3 != 0); //查找到满足条件开始
Reverse   翻转,颠倒
Distinct   消除重复
int[] factorsOf300 = { 2, 2, 3, 5, 5 }; 
  
    var uniqueFactors = factorsOf300.Distinct();  2,3,5

Union  //求并集

  int[] numbersA = { , , , , , ,  };
int[] numbersB = { , , , , }; var uniqueNumbers = numbersA.Union(numbersB); uniqueNumbers =, , , , , , ,,,
//A里面消除B里面的重复 求并集

Union

 

Intersect   //求交集

 int[] numbersA = { , , , , , ,  };
int[] numbersB = { , , , , }; var uniqueNumbers = numbersA.Intersect(numbersB); uniqueNumbers =,
//A里面消除B里面的重复 求交集

Except   //排除相同

 int[] numbersA = { , , , , , ,  };
int[] numbersB = { , , , , }; IEnumerable<int> aOnlyNumbers = numbersA.Except(numbersB);
aOnlyNumbers=,,,,

First     //第一条数据

ElementAt(int n)   //根据索引获取元素

Any

All

EqualAll   //全部等于

具体实践参考:https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b

 
 
 
 

linq——常用方法的更多相关文章

  1. Linq 常用方法解释

    /// <summary> /// linq /// </summary> public class Linq { /// <summary> /// 测试 /// ...

  2. Newtonsoft.Json.Linq 常用方法总结

    目录 1.Entity to Json 1.1.准备工作 1.2.Entity to Json 1.3.Json to Entity 2.Linq To Json 2.1.创建对象 2.2.从 Jso ...

  3. linq 总结

    linq 常用方法: top   var query=(from u in User ...).Take(10) dblinq的坑: 时间必须当参数传入,否则会报错 多个left join时,如果jo ...

  4. 进阶系列(9)——linq

    一.揭开linq的神秘面纱(一)概述  LINQ的全称是Language Integrated Query,中文译成“语言集成查询”.LINQ作为一种查询技术,首先要解决数据源的封装,大致使用了三大组 ...

  5. Linq中的常用方法

    System.Linq System.Linq.Enumerable  类 Range Repeat Reverse Select Where Sum Zip Aggregate Count Firs ...

  6. JS系列——Linq to js使用小结

    前言:前面几篇介绍了下C#基础技术中的几个:反射.特性.泛型.序列化.扩展方法.Linq to Xml等,本来还有两三个知识点没有写完,比如委托.多线程.异步等,后面会陆续将它们补起来,以便作为一套完 ...

  7. C# ~ 从 XML 到 Linq 到 Linq to XML

    .XML 可扩展标记语言 (Extensible Markup Language), 标记 (markup) 是关键部分,是标准通用标记语言 (Standard Generalized Markup ...

  8. Linq to 泛型集合查询集合包括大写M和年龄小于等于18

    #region Linq to 泛型集合查询集合包括大写M和年龄小于等于18            //List<Student> list = new List<Student&g ...

  9. MVC控制器常用方法返回类型

    控制器的常用方法 using System; using System.Collections.Generic; using System.Linq; using System.Web; using ...

随机推荐

  1. Conditional Expressions

    Conditional Expressions建立一些逻辑关系 The conditional expression classes from django.db import models clas ...

  2. what eats up the performance in the interior scene?

    - baseline (7w rps/core) - switch from large accelerator to regular accelerator (9w rps/core) - repl ...

  3. python 中使用 urllib2 伪造 http 报头的2个方法

    方法1. ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #!/usr/bin/pyth ...

  4. ocp最新考试题库:052新考题及答案整理-36

    36.Which two are true about roles? A) A role can be granted a combination of system and object privi ...

  5. STR[#6]

    photo 小明在旅游的路上看到了一条美丽的河,河上有许多船只,有的船只向左航行,有的船只向右航行.小明希望拍下这一美丽的风景,并且把尽可能多的船只都完整地拍到一张照片中. 小明位于河的边上,并且可以 ...

  6. python的数据结构分类,以及数字的处理函数,类型判断

    python的数据结构分类: 数值型 int:python3中都是长整形,没有大小限制,受限内存区域的大小 float:只有双精度型 complex:实数和虚数部分都是浮点型,1+1.2J bool: ...

  7. Ubuntu16.04装机后处理

    1.卸载软件 #卸载libreOffice sudo apt remove libreoffice-common #卸载amazon sudo apt remove unity-webapps-com ...

  8. 条目二十三《考虑用排序的vector替代关联容器》

    条目二十三<考虑用排序的vector替代关联容器> 在看到这个条目的标题的时候,说实话,我一下子是比较懵逼的.这个结论怎么和数据结构的时间复杂度不一致了? 一般来说,像map,set等关联 ...

  9. python全栈开发_day12_装饰器

    一:装饰器 1)什么是装饰器 装饰器的本质就是利用闭包,在满足开放(修改函数锁包含的功能)封闭(不改变源代码)的情况下完成操作. 2)装饰器的基本运用 def name_judge(f): def a ...

  10. docker 查看容器信息---格式化

    镜像,ID,端口号,状态 docker ps -a --format "table {{.Image}}\t{{.ID}}\t{{.Ports}}\t{{.Status}}" 列出 ...