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. bootstrap js插件

    导入JavaScript插件 Bootstrap除了包含丰富的Web组件之外,如前面介绍的下拉菜单.按钮组.导航.分页等.他还包括一些JavaScript的插件. Bootstrap的JavaScri ...

  2. text-decoration属性

    一.在CSS1中,text-decoration有六个值: text-decoration:none  //默认,定义标准的文本,没有任何样式,正常显示 text-decoration:underli ...

  3. 转:PHP之Traits

    原文来自于:http://www.cnblogs.com/tekkaman/archive/2012/12/12/2814214.html 1.Traits基础 2.优先级:当前类中的方法会覆盖 Tr ...

  4. sql restore mode

    refer : https://msdn.microsoft.com/en-us/library/ms189272.aspx SELECT name, recovery_model_desc FROM ...

  5. ASCII是指128个字符(不是256个)和ASCII Extended Characters(就是那些奇怪的外文字符)

    ASCII第一次以规范标准的型态发表是在1967年,最后一次更新则是在1986年,至今为止共定义了128个字元:其中33个字元无法显示(一些终端提供了扩展,使得这些字符可显示为诸如笑脸.扑克牌花式等8 ...

  6. Java中的属性与字段的区别

    Java中属性和字段的区别  Java中的属性,通常可以理解为其属名性时根据get和set方法名得出的. 其规则是:去掉get或set后其剩余的字符串,如果第二个字母是小写的,则把第一个字母也变成小写 ...

  7. poj 2503 Babelfish(字典树哈希)

    Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 29059 Accepted: 12565 Description You hav ...

  8. LightOJ 1135(线段树)

    题解引自:http://www.cnblogs.com/wuyiqi/archive/2012/05/27/2520642.html 题意: 有n个数,刚开始都为0 add i , j 给i,j区间内 ...

  9. Missing Number ——LeetCode

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

  10. win7使用USB转串口连接mini2440方法

    不想嚼别人吃剩的馍.我只说我自己是怎么痛苦的连上的. 环境设备: window7笔记本,没有串口,装有XP和Ubuntu2个虚拟机(不是必须的,我只是说明一下我的环境) 友善之臂mini2440(含U ...