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 ...
随机推荐
- 排他锁Lock
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Hotel
poj3667:http://poj.org/problem?id=3667 题目大意:Hotel有N(1 ≤ N ≤ 50,000)间rooms,并且所有的rooms都是连续排列在同一边,group ...
- GCD - Extreme (II)
uva11424: 题目:给出n,求gcd(1,2)+gcd(1,3)+gcd(2,3)+gcd(1,4)+gcd(2,4)+gcd(3,4)+...+gcd(1,n)+gcd(2,n)+...+gc ...
- JavaScript encodeURI() 函数
encodeURI() 函数可把字符串作为 URI 进行编码. -------------------------------------------------------------------- ...
- C++中强制变换之const_cast
今天学习了一下C++中的强制转换,看了const_cast,我发现了这个转换关键字的奇怪之处,于是把它记录一下,废话不说,先看一个程序: #include <iostream> using ...
- COJ 0970 WZJ的数据结构(负三十)树分治
WZJ的数据结构(负三十) 难度级别:D: 运行时间限制:1000ms: 运行空间限制:262144KB: 代码长度限制:2000000B 试题描述 给你一棵N个点的无根树,点和边上均有权值.请你设计 ...
- ZOJ 3469 Food Delivery
题目大意: 有n个人,住在一条直线上.第i个人的坐标是Xi,街上有个外卖餐馆的位置是X,现在餐厅工作人员要给街上的每个人送饭,送完之后再回到餐厅,送饭人的速度是V,每个人有个不满意值,当这个人送餐时间 ...
- POJ Countries in War 3114
题目大意: 给定一些城市,然后再给一些寄信的路信,A,B,H代表把信从A城市寄到B城市需要H小时. 如果没有直接可以寄达的,可以先通过另外一个城市到达,比如A,B可以寄信,B,C可以寄信,那么,A,C ...
- selenium grid 测试资料
像风一样自由的4篇博客: http://blog.csdn.net/five3/article/details/9671287 http://blog.csdn.net/five3/article/d ...
- Best Reward HDU 3613(回文子串Manacher)
题目大意:有一个串(全部由小写字母组成),现在要把它分成两部分,如果分开后的部分是回文串就计算出来它的价值总和,如果不是回文的那么价值就是0,最多能得到的最大价值. 分析:首先的明白这个最大价值有 ...