Linq101-Restriction
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的更多相关文章
- 关于Access restriction: The type 'Application' is not API (restriction on required library)
原文链接:http://rxxluowei.iteye.com/blog/671893 今天写第一次写JavaFX的入门程序就GG 遇到了导入API的问题,无奈疯狂地通过网络找解决方案.. 我的问题是 ...
- TNS-12540: TNS:internal limit restriction exceeded
应用程序以及客户端工具(Toad.PL/SQL Developer等)出现突然连接不上数据库服务器的情况,监听日志listener.log里面出现了TSN-12518与TSN-12540错误,如下所示 ...
- The constructor BASE64Encoder() is not accessible due to restriction on required library
在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示:Access restriction : T ...
- Access restriction: The type TaskTopicResolver is not accessible due to restrict
Access restriction: The type TaskTopicResolver is not accessible due to restrict : Eclipse 默认把这些受访问 ...
- Eclipse 关于“The type * is not accessible due to restriction on required library”问题的解决办法
The type * is not accessible due to restriction on required library”的错误, 意思是所需要的类库由于受限制无法访问. 解决办法: 1 ...
- Access restriction错误解决办法
Access restriction错误, XX方法 is not accessible due to restriction on required library XXlib 解决方案: Ecli ...
- Access restriction: The type 'BASE64Encoder' is not API
问题的原因好像是这个方法不是安全的,所以不推荐使用,我是在做毕设时要用到的所以就直接用了(毕设要求没有那么严格的要求)
- PHPExcel中open_basedir restriction in effect的解决方法
用PHPExcel做导出execl的时候发现在本地没有问题,但是把网站传到租用的服务器的时候就报错,具体如下: Warning: realpath() [function.realpath]: ope ...
- The constructor BASE64Encoder() is not accessible due to restriction on required
在Eclipse中编写Java代码时,用到了BASE64Decoder,import sun.misc.BASE64Decoder;可是Eclipse提示: Access restriction : ...
- 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 ...
随机推荐
- ZT: WEB学习资料
根据个人经验整理一些Web开发的一些技术书籍,希望对需要进入Web开发领域的TX有所指导,由于是在家里整理的,所有每本书对应的豆瓣链接打不开,如果整理有缺陷请多多指出. 入门篇:通过相关技术的全面基础 ...
- nodejs--book
https://github.com/0xlen/nodejs-wiki-book http://www.nodebeginner.org/index-zh-cn.html http://book.n ...
- Unity3d Material(材质) 无缝拼接
Unity3d Material(材质) Edit by @灰太龙 在做一个项目的过程中,遇到动态切换壁纸的功能,问题点在无缝拼接! 那我们先查查Unity3d 中的材质球,里面有个参数 Tiling ...
- Struts2 文件上传,下载,删除
本文介绍了: 1.基于表单的文件上传 2.Struts 2 的文件下载 3.Struts2.文件上传 4.使用FileInputStream FileOutputStream文件流来上传 5.使用Fi ...
- Compare Version Number
package cn.edu.xidian.sselab.string; /** * * @author zhiyong wang * title: Compare Version Numbers ...
- RC隔离 更新where条件列 没有索引的情况
CREATE TABLE `test100` ( `sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增编号', `phoneNo` int(11) , `c ...
- CSS样式中字体乱码
今天写程序时,明明设置了label标签的属性font-family:"微软雅黑"的,但是字体的显示的效果就是宋体,后来查看了一下网页源代码,结果发现设置的字体为中文的都是乱码,难怪 ...
- LVS+Keepalived+Nginx+Tomcat高可用负载均衡集群配置(DR模式,一个VIP,多个端口)
一.概述 LVS作用:实现负载均衡 Keepalived作用:监控集群系统中各个服务节点的状态,HA cluster. 配置LVS有两种方式: 1. 通过ipvsadm命令行方式配置 2. 通过Red ...
- excel时会弹出向程序发送命令时出现问题的提示框
出现此问题需要做两个操作来解决: 1.在开始所有程序中找到Microsoft Excel 2007的运行程序,右键选择属性,在兼容性标签将“以管理员身份运行此程序”的勾去掉. 2.在打开的Excel程 ...
- Simplify Path——LeetCode
Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...