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 ...
随机推荐
- linux主要目录的作用
手动敲一遍.算是加强记忆吧~ /:文件系统的入口,也是最高一级的目录 /bin:最基本的且着急用户和普通用户都可以使用的命令放在此目录下,如:ls.cp等 /boot:存放Linux的内核及引导系统所 ...
- 解决Ext.TextField的AllowBlank不能过滤空格代码
Ext过滤空格 重写了组件... Ext.apply(Ext.form.TextField.prototype, { validator : function(text) { if (this.all ...
- Jenkins 快速搭建持续集成环境
持续集成概述 什么是持续集成 随着软件开发复杂度的不断提高,团队开发成员间如何更好地协同工作以确保软件开发的质量已经慢慢成为开发过程中不可回避的问题.尤其是近些年来,敏捷(Agile) 在软件工程领域 ...
- Zabbix的集中式监控
相对于传统的ZABBIX硬件系统级监控(CPU,内存,硬盘,网卡),应用级的监控就显得有些复杂了. 如果对不同的应该来不同的应用,配置会很多的. 如果我们能在一个指定的AGENT上监控所有的APACH ...
- 牢记负载均衡与HA,高性能是不同的方案。一般的CLUSTER只能实现其中的一种,而ORACLE的RAC可以有两种。
F5/LVS<—Haproxy<—Squid/Varnish<—AppServer. 现在网站发展的趋势对网络负载均衡的使用是随着网站规模的提升根据不同的阶段来使用不同的技术: 第一 ...
- bit、sbin、sfr、sfr16 区别分析
1.bit 和 sbit 都是 C51 扩展的变量类型. bit 和 int char 之类的差不多,只不过 char=8 位, bit=1 位而已.都是变量,编译器在编译过程中分配地址.除非你指定, ...
- 揪出“凶手”——实战WinDbg分析电脑蓝屏原因
http://www.appinn.com/blue-screen-search-code/ 蓝屏代码查询器 – 找出蓝屏的元凶 11 文章标签: windows / 系统 / 蓝屏. 蓝屏代码查询器 ...
- IMAP与POP3的区别
POP3协议允许电子邮件客户端下载服务器上的邮件,但是在客户端的操作(如移动邮件.标记已读等),不会反馈到服务器上.比如通过客户端收取了邮箱中的2封邮件并移动到其他文件夹,邮箱服务器上的这些邮件是没有 ...
- BZOJ 1059 [ZJOI2007]矩阵游戏
1059: [ZJOI2007]矩阵游戏 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2707 Solved: 1322[Submit][Stat ...
- -_-#【jQuery插件】textSlider 文本滚动
jQuery.textSlider.js ;(function($) { $.fn.textSlider = function(settings) { settings = jQuery.extend ...