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. ASP.NET关于引用bootstrap.css导致Gridview Header无法居中

    HorizontalAlign="Center"  属性因不知名原因被覆盖掉. 可以使用<HeaderStyle  CssClass="text-center&qu ...

  2. RH6030 单通道触摸感应开关

    1.概述: RH6030 是一款单通道电容式触摸感应控制开关IC,可以替代传统的机械式开关. 该 IC 采用CMOS 工艺制造,结构简单,性能稳定.IC 可通过外部引脚配置成多种工作模式,可广泛应用于 ...

  3. Caption,Text,WindowText的区别——TControl也有FText,是为了模拟一个窗口

    TControl = class(TComponent) // 控件的Windows功能从TControl开始 property Caption: TCaption read GetText writ ...

  4. c# 类;一维数组;二维数组

    1. 输入邮箱帐号,判断格式是否正确  (1)有且只有一个@          Contains IndexOf ==LastIndexOf  (2)不能以@开头           StartsWi ...

  5. Spark运行各个时间段的解释

    package org.apache.spark.ui private[spark] object ToolTips {  val SCHEDULER_DELAY =    ""& ...

  6. C参数计算

    C‘计算参数时,从右向左压栈的 int a[]={1,3,4}; int * ptr=a; pirntf("%d,%d\n",*ptr,*(++ptr)); 输出都是3:

  7. 【HDOJ】2531 Catch him

    简单BFS.就是要把所有的D点当成一个整体考虑(整体移动). /* 2531 */ #include <iostream> #include <queue> #include ...

  8. java学习面向对象值static

    讲完了this这个关键字,我们继续前进,这节我们讲另外一个比较重要的东东,java当中的static,在main函数前面这个家伙都在那里一直挺着,你瞅见了么,你就不好奇么,你就不想知道他杵在那里做什么 ...

  9. WordPress BuddyPress Extended Friendship Request插件跨站脚本漏洞

    漏洞名称: WordPress BuddyPress Extended Friendship Request插件跨站脚本漏洞 CNNVD编号: CNNVD-201307-609 发布时间: 2013- ...

  10. [Sequence Alignment Methods] Cross-Recurrent Plot (CRP)

    A recurrence plot (RP) is a straightforward way to visualize characteristics of similar system state ...