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 ...
随机推荐
- www.nt-kaisheng.com
线号机耗材网站开发架构,是基于丽标线号机_凯标线号机_耗材|色带|号码管批发|电缆标牌_南通凯胜电器有限公司,进行的服务需求的网站. 南通凯胜电器有限公司网站与手工编码比起来,HTML5框架在准确性和 ...
- 登录远程SQL服务器
一 看ping 服务器IP能否ping通. 这个实际上是看和远程sql server 2000服务器的物理连接是否存在.如果不行,请检查网络,查看配置,当然得确保远程sql server 2000服务 ...
- [BZOJ 1801] [Ahoi2009]chess 中国象棋 【DP】
题目链接:BZOJ - 1801 题目分析 对于50%的数据是可以直接状压 DP 的. 对于100%的数据,使用递推的 DP .(或者这只叫递推不叫 DP ?) 可以发现,每一行和每一列的棋子个数不能 ...
- 图片的css自适应
当需要css来缩放图片的时候,可以采用外层容器100%或者任意百分比, 内层图片img tag 没有宽高,用sass写经过断点后的mixin中的样式就是这样: .workscon_section{ w ...
- Multiple
poj1465:http://poj.org/problem?id=1465 题意:给你一个数n(0~4999):以及m个不同十进制的数,问有这些十进制数组成的最小的n的倍数是多少.如果有则输出,没有 ...
- LINUX HA:Pacemaker + Corosync初配成功
参考很多文档: http://zhumeng8337797.blog.163.com/blog/static/100768914201218115650522/ 下一步,想想这个PC组和与HAPROX ...
- 本地yum源
<pre name="code" class="html">1.为DVD创建一个挂载目录 [root@localhost ~]# mkdir /me ...
- (转载)在Linux下删除文件行末尾的^M符号方法
(转载)http://www.xinfengit.com/200907/1433646.html 由于DOS下的编辑器和linux(linux教程 linux培训 )编辑器对文件行末的回车符处理不一致 ...
- Python 实时日志平台 Sentry
原文地址:http://www.oschina.net/p/sentry Sentry 是一个实时的事件日志和聚合平台,基于 Django 构建. Sentry 可以帮助你将 Python 程序的所有 ...
- 在C#中internal关键字是什么意思?
这个回答的很不错 :http://zhidao.baidu.com/link?url=BGmYomZnf_-94L4uPXa-gzYMssL5HGmZyk_fFG7x4i4z_vL8qN3o7CrJg ...