using System;
using System.Collections.Generic;
using System.Linq; namespace Linq101
{
class Quantifiers
{
/// <summary>
/// This sample uses Any to determine if any of the words in the array contain the substring 'ei'.
/// </summary>
public void Linq67()
{
string[] words = { "believe", "relief", "receipt", "field" }; bool iAfterE = words.Any(w => w.Contains("ei")); Console.WriteLine("There is a word that contains in the list that contains 'ei': {0}", iAfterE);
} /// <summary>
/// This sample uses Any to return a grouped a list of products only for categories that have at least one product that is out of stock.
/// </summary>
public void Linq68()
{
List<Data.Product> products = Data.GetProductList();
var productGroups = from p in products
group p by p.Category
into g
where g.Any(p => p.UnitsInStock == )
select new { Category = g.Key, Products = g }; ObjectDumper.Write(productGroups, );
} /// <summary>
/// This sample uses All to determine whether an array contains only odd numbers.
/// </summary>
public void Linq69()
{
int[] numbers = { , , , , , , }; bool onlyOdd = numbers.All(n => n % == ); Console.WriteLine("The list contains only odd numbers : {0}", onlyOdd);
} /// <summary>
/// This sample uses All to return a grouped a list of products only for categories that have all of their products in stock.
/// </summary>
public void Linq70()
{
List<Data.Product> products = Data.GetProductList(); var productGroups = from p in products
group p by p.Category
into g
where g.All(p => p.UnitsInStock > )
select new { Category = g.Key, products = g }; ObjectDumper.Write(productGroups, );
}
}
}

Linq101-Quantifiers的更多相关文章

  1. 6-1 Quantifiers

    1 Quantifiers are used to describe the number or amount of something. Certain quantifiers are used w ...

  2. Discrete Mathematics and Its Applications | 1 CHAPTER The Foundations: Logic and Proofs | 1.4 Predicates and Quantifiers

    The statements that describe valid input are known as preconditions and the conditions that the outp ...

  3. 正则表达式中的Quantifiers

    ?: Match an element zero or one time 例如: colou?r: color 或 colour 但不能是 colo2r *: Match an element zer ...

  4. 101个LINQ示例,包含几乎全部操作

    Restriction Operators Where - Simple public void Linq1() { , , , , , , , , , }; var lowNums = from n ...

  5. Linq编程101例

    原文地址:101 LINQ Samples in C# Part1 - Restriction Operators Part2 - Projection Operators Part3 - Parti ...

  6. 原生JS:RegExp对象详解

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  7. 《Java学习笔记(第8版)》学习指导

    <Java学习笔记(第8版)>学习指导 目录 图书简况 学习指导 第一章 Java平台概论 第二章 从JDK到IDE 第三章 基础语法 第四章 认识对象 第五章 对象封装 第六章 继承与多 ...

  8. C#基础知识简单梳理

    本文是转发博友的总结,方便自己以后随时温习: 1.值类型和引用类型 1.1堆和栈 简单的说值类型存放在堆栈上面,引用类型的数据存放在托管堆上面(它的引用地址却存放在堆栈上面)! 栈:它是一个内存数组, ...

  9. PHP正则表达式详解(一)

    前言: 半年前我对正则表达式产生了兴趣,在网上查找过不少资料,看过不少的教程,最后在使用一个正则表达式工具RegexBuddy时,发现他的教程写的非常好,可以说是我目前见过最好的正则表达式教程.于是一 ...

随机推荐

  1. 开源中国iOS客户端学习

    开源中国iOS客户端学习 续写前言 <开源中国iOS客户端学习>续写前系列博客    http://blog.csdn.net/column/details/xfzl-kykhd.html ...

  2. Eclipse 代码自动补全

    使用Eclipse开发Android时,发现代码补全功能太差,完全不像VS似的,输入一个字母就出现代码提示. 下面是在Eclipse中实现类似VS代码补全的方法: ①打开Eclipse->Win ...

  3. Can deep learning help you find the perfect girl?

    Can deep learning help you find the perfect girl? One of the first things I did when I moved to Mont ...

  4. 【技术贴】解决使用maven jetty启动后无法加载修改过后的静态资源

    如何使用jetty自动热部署修改后的所有文件,比如js,jpg,class等,哇咔咔 太爽啦比tomcat舒服多了. jetty模式是不能修改js文件的,比如你现在调试前端js,发现在myeclips ...

  5. PlatformTransactionManager

    Spring Boot 使用事务非常简单,首先使用注解 @EnableTransactionManagement 开启事务支持后,然后在访问数据库的Service方法上添加注解 @Transactio ...

  6. 【转】Java删除文件夹和文件

    原文网址:http://kxjhlele.iteye.com/blog/323657 以前在javaeye看到过关于Java操作文件的一篇文章,写的很好,但找了半天也没找到,就把找到底几篇文章整理一下 ...

  7. 高级数据结构(树状数组套主席树):ZOJ 2112 Dynamic Rankings

    Dynamic Rankings Time Limit: 10 Seconds      Memory Limit: 32768 KB The Company Dynamic Rankings has ...

  8. 在Ubuntu中安装Redis

    原文地址:http://blog.fens.me/linux-redis-install/ 在Ubuntu中安装Redis R利剑NoSQL系列文章,主要介绍通过R语言连接使用nosql数据库.涉及的 ...

  9. 洛谷2583 地铁间谍 (UVa1025A Spy in the Metro)

    洛谷2583 地铁间谍(UVa1025A Spy in the Metro) 本题地址:http://www.luogu.org/problem/show?pid=2583 题目描述 特工玛利亚被送到 ...

  10. 《University Calculus》-chaper8-无穷序列和无穷级数-p级数

    Q:定义p级数有如下形式,讨论p级数的敛散性.(p>o) 我们以p = 1作为分界点,因为实践表明这个分界点是最优区分度的.那么下面我们进行分情况讨论. 在这之前,我们有必要先引入一个检验敛散性 ...