Linq101-Partitioning
using System;
using System.Linq; namespace Linq101
{
class Partitioning
{
/// <summary>
/// This sample uses Take to get only the first 3 elements of the array.
/// </summary>
public void Linq20()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.Take(); Console.WriteLine("First 3 numbers:");
foreach (var n in query)
{
Console.WriteLine(n);
}
} /// <summary>
/// This sample uses Take to get the first 3 orders from customers in Washington.
/// </summary>
public void Linq21()
{
var customers = Data.GetCustomerList(); var query = (from c in customers
from o in c.Orders
where c.Region == "WA"
select new { c.CustomerID, o.OrderID, o.OrderDate })
.Take(); //var query = (from c in customers
// where c.Region == "WA"
// from o in c.Orders
// select new { c.CustomerID, o.OrderID, o.OrderDate })
// .Take(3); Console.WriteLine("First 3 orders in WA:");
foreach (var order in query)
{
ObjectDumper.Write(order);
}
} /// <summary>
/// This sample uses Skip to get all but the first 4 elements of the array.
/// </summary>
public void Linq22()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.Skip(); Console.WriteLine("All but first 4 numbers:");
foreach (var n in query)
{
Console.WriteLine(n);
}
} /// <summary>
/// This sample uses Take to get all but the first 2 orders from customers in Washington.
/// </summary>
public void Linq23()
{
var customers = Data.GetCustomerList(); var query = (from c in customers
where c.Region == "WA"
from o in c.Orders
select new { c.CustomerID, o.OrderID, o.OrderDate })
.Skip(); foreach (var order in query)
{
ObjectDumper.Write(order);
}
} /// <summary>
/// This sample uses TakeWhile to return elements starting from the beginning of the array until a number is hit that is not less than 6.
/// </summary>
public void Linq24()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.TakeWhile(n => n < ); foreach (var n in query)
{
Console.WriteLine(n);
}
} /// <summary>
/// This sample uses TakeWhile to return elements starting from the beginning of the array until a number is hit that is less than its position in the array.
/// </summary>
public void Linq25()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.TakeWhile((number, index) => number > index); foreach (var n in query)
{
Console.WriteLine(n);
}
} /// <summary>
/// This sample uses SkipWhile to get the elements of the array starting from the first element divisible by 3.
/// </summary>
public void Linq26()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.SkipWhile(n => n % != ); foreach (var n in query)
{
Console.WriteLine(n);
}
} /// <summary>
/// This sample uses SkipWhile to get the elements of the array starting from the first element less than its position.
/// </summary>
public void Linq27()
{
int[] numbers = { , , , , , , , , , }; var query = numbers.SkipWhile((number, index) => number > index); foreach (var n in query)
{
Console.WriteLine(n);
}
}
}
}
Linq101-Partitioning的更多相关文章
- [LeetCode] Palindrome Partitioning II 拆分回文串之二
Given a string s, partition s such that every substring of the partition is a palindrome. Return the ...
- [LeetCode] Palindrome Partitioning 拆分回文串
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- Leetcode: Palindrome Partitioning II
参考:http://www.cppblog.com/wicbnu/archive/2013/03/18/198565.html 我太喜欢用dfs和回溯法了,但是这些暴力的方法加上剪枝之后复杂度依然是很 ...
- 測試大型資料表的 Horizontal Partitioning 水平切割
FileGroup 檔案群組 :一個「資料庫(database)」可對應一或多個 FileGroup,一個 FileGroup 可由一或多個 file (.ndf) 構成. FileGroup 可讓 ...
- UVA - 11584 Partitioning by Palindromes[序列DP]
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...
- LintCode Palindrome Partitioning II
Given a string s, cut s into some substrings such that every substring is a palindrome. Return the m ...
- How to Remove Table Partitioning in SQL Server
In this article we will see how we can remove partitions from a table in a database in SQL server. I ...
- Partitioning & Archiving tables in SQL Server (Part 2: Split, Merge and Switch partitions)
Reference: http://blogs.msdn.com/b/felixmar/archive/2011/08/29/partitioning-amp-archiving-tables-in- ...
- Partitioning & Archiving tables in SQL Server (Part 1: The basics)
Reference: http://blogs.msdn.com/b/felixmar/archive/2011/02/14/partitioning-amp-archiving-tables-in- ...
- LeetCode(131)Palindrome Partitioning
题目 Given a string s, partition s such that every substring of the partition is a palindrome. Return ...
随机推荐
- MVC身份验证及权限管理
MVC自带的ActionFilter 在Asp.Net WebForm的中要做到身份认证微软为我们提供了三种方式,其中最常用的就是我们的Form认证,需要配置相应的信息.例如下面的配置信息: < ...
- BZOJ 2432 兔农
Description 农夫栋栋近年收入不景气,正在他发愁如何能多赚点钱时,他听到隔壁的小朋友在讨论兔子繁殖的问题. 问题是这样的:第一个月初有一对刚出生的小兔子,经过两个月长大后,这对兔子从第三个月 ...
- BZOJ 1032 祖玛
Description 这是一个流行在Jsoi的游戏,名称为祖玛.精致细腻的背景,外加神秘的印加音乐衬托,彷佛置身在古老的国度里面,进行一个神秘的游戏——这就是著名的祖玛游戏.祖玛游戏的主角是一只石青 ...
- cf C On Number of Decompositions into Multipliers
题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个. 思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积 ...
- dwr消息推送和tomcat集群
网友的提问: 项目中用到了dwr消息推送.而服务端是通过一个http请求后 触发dwr中的推送方法.而单个tomcat中.服务器发送的http请求和用户都在一个tomcat服务器中.这样就能精准推送到 ...
- Function语义学之member function
之前我们讲过编译器会对 nonmember functions 进行怎样的扩充和该写,今天我们来讲一下 member functions 函数调用方式 一.Nonstatic Member Funct ...
- POJ 3180 The Cow Prom(强联通)
题目大意: 约翰的N(2≤N≤10000)只奶牛非常兴奋,因为这是舞会之夜!她们穿上礼服和新鞋子,别上鲜花,她们要表演圆舞. 只有奶牛才能表演这种圆舞.圆舞需要一些绳索和一个圆形的 ...
- C#代码实现隐藏任务栏、开始菜单和禁用任务管理
一:截图,主要是调用系统接口和更改注册表实现功能 二:代码 using System; using System.Collections.Generic; using System.Linq; usi ...
- FreeMarker-TemplateLoader
Java中不乏优秀的模板引擎,Velocity,mvel,FreeMarker等.在构建框架的时候,通常可以拿来即用,但我们需要控制它.最近需要一个数据准备的框架,便选择了FreeMarker,Fre ...
- 由浅入深吃透MVC框架,驯服烂代码
MVC 已经成为客户端的主流编程框架,相信客户端工程师对它并不陌生,甚至在开发过程中,不通过思考都会自动使用 MVC 框架编程.但在工作过程中,发现许多小伙伴也只是使用 MVC,对于为什么这样使用并不 ...