using System;
using System.Linq; namespace Linq101
{
class Restriction
{
/// <summary>
/// This sample uses where to find all elements of an array less than 5.
/// </summary>
public void Linq1()
{
int[] numbers = { , , , , , , , , , }; var query = from n in numbers
where n <
select n; Console.WriteLine("Numbers < 5 :");
foreach (var number in query)
{
Console.WriteLine(number);
}
} /// <summary>
/// This sample uses where to find all products that are out of stock.
/// </summary>
public void Linq2()
{
var productList = Data.GetProductList(); var query = from product in productList
where product.UnitsInStock ==
select product; Console.WriteLine("Sold out products:");
foreach (var product in query)
{
Console.WriteLine("{0} is sold out!", product.ProductName);
}
} /// <summary>
/// This sample uses where to find all products that are in stock and cost more than 3.00 per unit.
/// </summary>
public void Linq3()
{
var productList = Data.GetProductList(); var query = from product in productList
where product.UnitsInStock > && product.UnitPrice > 3.00M
select product; Console.WriteLine("In-stock products that cost more than 3.00:");
foreach (var product in query)
{
Console.WriteLine("{0} is in stock and cost more than 3.00", product.ProductName);
}
} /// <summary>
/// This sample uses where to find all customers in Washington and then uses the resulting sequence to drill down into their orders.
/// </summary>
public void Linq4()
{
var customerList = Data.GetCustomerList(); var query = from customer in customerList
where customer.Region == "WA"
select customer; Console.WriteLine("Cutomers from Washington and their orders:");
foreach (var customer in query)
{
Console.WriteLine("Customer {0}:{1}", customer.CustomerID, customer.CompanyName);
foreach (var order in customer.Orders)
{
Console.WriteLine(" Order {0}:{1}", order.OrderID, order.OrderDate);
}
}
} /// <summary>
/// This sample demonstrates an indexed Where clause that returns digits whose name is shorter than their value.
/// </summary>
public void Linq5()
{
string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var query = digits.Where((digit, index) => digit.Length < index); Console.WriteLine("Short digits:");
foreach (var digit in query)
{
Console.WriteLine("The word {0} is shorter than its value.", digit);
}
}
}
}

Linq101-Restriction的更多相关文章

  1. 关于Access restriction: The type 'Application' is not API (restriction on required library)

    原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是 ...

  2. TNS-12540: TNS:internal limit restriction exceeded

    应用程序以及客户端工具(Toad.PL/SQL Developer等)出现突然连接不上数据库服务器的情况,监听日志listener.log里面出现了TSN-12518与TSN-12540错误,如下所示 ...

  3. The constructor BASE64Encoder() is not accessible due to restriction on required library

    在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示:Access restriction : T ...

  4. Access restriction: The type TaskTopicResolver is not accessible due to restrict

    Access restriction: The type TaskTopicResolver is not accessible due to restrict :  Eclipse 默认把这些受访问 ...

  5. Eclipse 关于“The type * is not accessible due to restriction on required library”问题的解决办法

    The type * is not accessible due to restriction on required library”的错误, 意思是所需要的类库由于受限制无法访问. 解决办法: 1 ...

  6. Access restriction错误解决办法

    Access restriction错误, XX方法 is not accessible due to restriction on required library XXlib 解决方案: Ecli ...

  7. Access restriction: The type 'BASE64Encoder' is not API

    问题的原因好像是这个方法不是安全的,所以不推荐使用,我是在做毕设时要用到的所以就直接用了(毕设要求没有那么严格的要求)

  8. PHPExcel中open_basedir restriction in effect的解决方法

    用PHPExcel做导出execl的时候发现在本地没有问题,但是把网站传到租用的服务器的时候就报错,具体如下: Warning: realpath() [function.realpath]: ope ...

  9. The constructor BASE64Encoder() is not accessible due to restriction on required

    在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示: Access restriction : ...

  10. Eclipse 编译错误 Access restriction:The type *** is not accessible due to restriction on... 解决方案

    报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C ...

随机推荐

  1. Node.js REPL终端

    REPL表示读取评估和演示打印循环(Read Eval Print Loop),它代表一个命令输入和系统在交互模式的输出响应窗口控制台或Unix/ Linux的shell计算机环境. Node.js附 ...

  2. Children of the Candy Corn

    poj3083:http://poj.org/problem?id=3083 题意:给你一个迷宫,然后给你一个起点和终点,现在给你种规则,一种是先向左,无法向左则向前,无法向前则向右,否则则向后,另外 ...

  3. Struts2 权限验证

    之前的Struts2项目通过再Sitemesh的母版页中使用Struts的if标签进行了session判断,使得未登录的用户不能看到页面,但是这 种现仅仅在view层进行,如果未登录用户直接在地址栏输 ...

  4. 设置Tomcat默认界面

    修改配置文件:         首先,修改$tomcat/conf/server.xml文件.      在server.xml文件中,有一段如下:      ……      <engine   ...

  5. 利用over开窗函数取第一条记录

    SQL> set linesize 200 SQL> select * from (select a.* ,row_number() over( order by empno) rn  f ...

  6. VIM大作战之C++简易集成编译环境(Windows篇)

    一切都要从这篇文章说起 Vim 实在是精致独特得有点像个林妹妹.但谁要是希望家里也有个林妹妹,光把自家丫头照着绣像打扮打扮是不行的,必须从零开始养成一个.而且就算真能养出来个“天上掉下来”一般的可人儿 ...

  7. Building a Space Station(kruskal,说好的数论呢)

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 3820   Accepted: 1950 Description You a ...

  8. bzoj1135

    POI阴影又发作了但这道题挺好的,比较涨知识裸的想法是裸的每次二分图匹配,但显然会TLE这里就要引入Hall定理:二分图G中的两部分顶点组成的集合分别为X, Y, X={X1, X2, X3,X4,. ...

  9. 图论(网络流):[SCOI2015]小凸玩矩阵

    Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最 ...

  10. 字符串(LCT,后缀自动机):BZOJ 2555 SubString

    2555: SubString Time Limit: 30 Sec  Memory Limit: 512 MBSubmit: 1620  Solved: 471 Description 懒得写背景了 ...