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 ...
随机推荐
- BZOJ 1009 GT考试
Description 阿申准备报名参加GT考试,准考证号为N位数X1X2....Xn(0<=Xi<=9),他不希望准考证号上出现不吉利的数字.他的不吉利数学A1A2...Am(0< ...
- [BZOJ 1072] [SCOI2007] 排列perm 【状压DP】
题目链接:BZOJ 1072 这道题使用 C++ STL 的 next_permutation() 函数直接暴力就可以AC .(使用 Set 判断是否重复) 代码如下: #include <io ...
- 解决maven仓库有jar包但是maven程序无法下载仓库jar包
话说,这个问题困扰了我两个多月了已经~~~ 后来发现不知道被谁动了,把我的仓库没有放到仓库组里面~~~ 用admin登录进去,默认密码是admin123,然后看截图操作吧. (记得删除你本地报错说** ...
- "Ray, Pass me the dishes!"
uvaLive3938:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...
- Struts2 文件上传,下载,删除
本文介绍了: 1.基于表单的文件上传 2.Struts 2 的文件下载 3.Struts2.文件上传 4.使用FileInputStream FileOutputStream文件流来上传 5.使用Fi ...
- AlgorithmsI PA2: Randomized Queues and Deques Subset
本题的bonus是 因此方法是queue的size 达到了K, 就停止增加元素,保证queue.size() 最大时只有k. Java code: import edu.princeton.cs.al ...
- datetime和timer的使用(小小幻灯片)
一:展示图片 每秒换一次图片,一共六十张图片,00-59 二:代码 a,设计代码 namespace timePicture { partial class Form1 { /// <summa ...
- IIS的安装与配置
IIS的安装与配置 5.1.1. IIS安装视频教程 5.1.2. IIS配置与建站设置视频教程 IIS是什么 IIS是Internet Information Services(Internet信息 ...
- IGeometry 中取指定的点
private static IGeometryCollection MakeMultiPoint(IGeometry geometry,int pointcount) { IGeo ...
- 动态规划——G 回文串
G - 回文串 Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Stat ...